How can I have loop inside another big loop?
1 回表示 (過去 30 日間)
古いコメントを表示
Hi, I have 3 channel data, I added noise to ch1 to calculate SNR. This needs to repeat 10 times as I am adding WGN which is in loop called i_loop. How can I merge these loops together? I wrote something like below but it does't work. First I want to calculate SNRs for all channels then I need to move to another noise using i_loop. Could you plz help me?
for i_loop = 1:10
for iChan = 1:NumChannel
[SNR((i_loop),iChan)]=SNR_F(Sig(iChan,:),Noisy_Sig(iChan,:),Filtered_Sig(iChan,:));
end
end
where SNR-F is SNR calculation function.
1 件のコメント
Dennis
2018 年 7 月 6 日
編集済み: Dennis
2018 年 7 月 6 日
From my perspective i_loop doesn't do anything other than repeating your other loop 10 times, so you end up with 10 times the same result in SNR. Where do you add WGN and to what?
for i_loop = 1:10
%insert WGN here
for iChan = 1:NumChannel
[SNR((i_loop),iChan)]=SNR_F(Sig(iChan,:),Noisy_Sig(iChan,:),Filtered_Sig(iChan,:));
end
end
It also really helps if you describe your problem a little bit better. Doesn't work is a horrbile description because it could mean you get an error message, wrong results, strange output etc.
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!