simple coding, how to write (x-1)...(x-n)
Mostrar comentarios más antiguos
How would i write (x-1)(x-2)....(x-n)
for a given n in matlab
Respuestas (2)
Image Analyst
el 5 de Sept. de 2016
Try this:
result = 1
for k = 1 : n
result = result * (x - k);
end
2 comentarios
ahmed lamak
el 5 de Sept. de 2016
Image Analyst
el 5 de Sept. de 2016
You can do this:
result = 1
for k = 1 : length(z)
result = result * (x - z(k));
end
The simplest solution, without any loops:
prod(x-z)
2 comentarios
Walter Roberson
el 5 de Sept. de 2016
I do not understand why you are raising to the z'th power ??
Stephen23
el 5 de Sept. de 2016
@Walter Roberson: experimenting around, and not paying enough attention to the copy-and-paste :(
Categorías
Más información sobre Polynomials en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!