For loop using two variables

1 view (last 30 days)
HyoJae Lee
HyoJae Lee on 26 May 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.

Answers (1)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 26 May 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

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!