フィルターのクリア

how to program given formula

1 回表示 (過去 30 日間)
Avenger2020
Avenger2020 2020 年 11 月 7 日
編集済み: Avenger2020 2020 年 11 月 7 日
Neeed help on how to write this formula in matlab.
if n=100
i=(1,.....,n)

採用された回答

VBBV
VBBV 2020 年 11 月 7 日
編集済み: VBBV 2020 年 11 月 7 日
% if true
% code
% end
x= 1:100;y = linspace(2,250,length(x));
Fx = diff(x,1);
Fy = diff(y,1);
L = sqrt(Fx.^2 + Fy.^2);
  1 件のコメント
Avenger2020
Avenger2020 2020 年 11 月 7 日
編集済み: Avenger2020 2020 年 11 月 7 日
what if the i-1 doesn't mean a actual value of 1 and it means to minus the previous x and y values. so if the first x value is 14 and the second x value is 16 it means to minus 16 from 14. For example, x2=xi=16 and x2-x1=xi-1=14. is there a way to program it to call the previous values and minus them? sp its basically saying the xi is the "i" th value in the matric and the "i-1" is the "i" value minus the previous value in sequence.

サインインしてコメントする。

その他の回答 (1 件)

Bryant Pong
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

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by