n+1 in formula

13 ビュー (過去 30 日間)
B
B 2019 年 7 月 3 日
回答済み: Dheeraj Singh 2019 年 7 月 17 日
Hi, could someone help me to put the next formula in matlab?
The sum goes to n-1: 1/2*T* sum(abs(AP[n+1]*ML[n] - AP[n]*ML[n+1])).
The main problem is the n+1 how can i do this.
  3 件のコメント
Stephen23
Stephen23 2019 年 7 月 3 日
B's "Answer" moved here:
Is this better? AP and ML are about the x and y coordinates when someone is standing still.
Raj
Raj 2019 年 7 月 3 日
編集済み: Raj 2019 年 7 月 3 日
" main problem is the n+1 " I am still not quite sure what is the problem. Is this what you are looking for?
count=0;
for n=1:N-1
count=count+abs((AP(n+1)*ML(n))-(AP(n)*ML(n+1)));
end
count=(0.5*count)/T;

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

回答 (1 件)

Dheeraj Singh
Dheeraj Singh 2019 年 7 月 17 日
Hi,
I understand that by “put” you mean you want to implement it without using loops.
The following code implements the above formula without using loops using random values of “AP” and “ML”
T=2;
n=100
AP=rand(n,1);
ML=rand(n,1);
i=1:n-1;
j=i+1;
val=sum(abs(AP(j).*ML(i)-AP(i).*ML(j)))/(2*T)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by