How can I have loop inside another big loop?

1 visualizzazione (ultimi 30 giorni)
Mahdi Torabi
Mahdi Torabi il 6 Lug 2018
Modificato: Dennis il 6 Lug 2018
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 Commento
Dennis
Dennis il 6 Lug 2018
Modificato: Dennis il 6 Lug 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.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by