For loop using two variables

6 ビュー (過去 30 日間)
HyoJae Lee
HyoJae Lee 2021 年 5 月 26 日
回答済み: Sulaymon Eshkabilov 2021 年 5 月 26 日
for ta=15:1:500
for va=ta-14:1:ta+15 & na=1:1:30
xx(na,1)=rrr(va,1);
end
end
I want to make a loop that va and na is running simultaneously.
for example ,
for the inner loop,
xx(1,1)=rrr(ta-14,1)
xx(2,1)=rrr(ta-13,1)
xx(3,1)=rrr(ta-12,1)
...
xx(30,1)=rrr(ta+15,1)
I want to run like this.
I dont know how to revise my code. I need your help.
Thanks.

回答 (1 件)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021 年 5 月 26 日
Hi,
Here is the corrected code:
xx=zeros(numel(va), nume(na));
for va=1:1500
for na=1:30
xx(va, na)=rrr(va,na);
end
end

カテゴリ

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