For loop using two variables

2 Ansichten (letzte 30 Tage)
HyoJae Lee
HyoJae Lee am 26 Mai 2021
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.

Antworten (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov am 26 Mai 2021
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

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by