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
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 个)

类别

Help CenterFile Exchange 中查找有关 Just for fun 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by