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!