how to program given formula
1 次查看(过去 30 天)
显示 更早的评论
Neeed help on how to write this formula in matlab.
if n=100
i=(1,.....,n)
0 个评论
采纳的回答
更多回答(1 个)
Bryant Pong
2020-11-7
Assuming that you have arrays of values for x and y:
n = 100;
% Preallocate memory to save some time (n - 1 values)
l = zeros(1, n - 1);
for i = 2:100
deltaX = x(i) - x(i - 1);
deltaY = y(i) - y(i - 1);
l(i - 1) = sqrt(deltaX^2 + deltaY^2);
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!