How can I have loop inside another big loop?
1 view (last 30 days)
Show older comments
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 Comment
Dennis
on 6 Jul 2018
Edited: Dennis
on 6 Jul 2018
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.
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!