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!