simple coding, how to write (x-1)...(x-n)
이전 댓글 표시
How would i write (x-1)(x-2)....(x-n)
for a given n in matlab
답변 (2개)
Image Analyst
2016년 9월 5일
Try this:
result = 1
for k = 1 : n
result = result * (x - k);
end
댓글 수: 2
ahmed lamak
2016년 9월 5일
Image Analyst
2016년 9월 5일
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
Walter Roberson
2016년 9월 5일
I do not understand why you are raising to the z'th power ??
Stephen23
2016년 9월 5일
@Walter Roberson: experimenting around, and not paying enough attention to the copy-and-paste :(
카테고리
도움말 센터 및 File Exchange에서 Polynomials에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!