simple coding, how to write (x-1)...(x-n)
조회 수: 1 (최근 30일)
이전 댓글 표시
How would i write (x-1)(x-2)....(x-n)
for a given n in matlab
댓글 수: 0
답변 (2개)
Image Analyst
2016년 9월 5일
Try this:
result = 1
for k = 1 : n
result = result * (x - k);
end
댓글 수: 2
Image Analyst
2016년 9월 5일
You can do this:
result = 1
for k = 1 : length(z)
result = result * (x - z(k));
end
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!