필터 지우기
필터 지우기

Nesting smaller loops under a bigger loop

조회 수: 1 (최근 30일)
Hasan Isomitdinov
Hasan Isomitdinov 2022년 10월 8일
답변: Ghazwan 2022년 10월 8일
sumtable=zeros(4,9);
cutoff=20;
for i=1:nrf
sumtable(1,i)=mean(mean(vdprop(:,:,i)));
end
for i=1:nrf
sumtable(1,i+3)=mean(mean(vdprop(1:cutoff,:,i)));
end
for i=1:nrf
sumtable(1,i+6)=mean(mean(vdprop(cutoff+1:end,:,i)));
end
How can I nest the above three loops into another bigger loop?

답변 (1개)

Ghazwan
Ghazwan 2022년 10월 8일
assuming you have the value of nrf. Another outside loop would be:
sumtable=zeros(4,9);
cutoff=20;
for ii=1:20 %or whatever number you need instead of 20
for i=1:nrf
sumtable(1,i)=mean(mean(vdprop(:,:,i)));
end
for i=1:nrf
sumtable(1,i+3)=mean(mean(vdprop(1:cutoff,:,i)));
end
for i=1:nrf
sumtable(1,i+6)=mean(mean(vdprop(cutoff+1:end,:,i)));
end
end

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by