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!