For loop using two variables
조회 수: 1 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
답변 (1개)
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!