For loop using two variables

1 次查看(过去 30 天)
HyoJae Lee
HyoJae Lee 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
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 CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by