Is it possible to do a for loop of this code?

Hi,
sigma1cm0 = std(cm0_1); sigma1cmA = std(cmA_1);
sigma1cmq = std(cmq_1); sigma1cmE = std(cmE_1);
The size of cm0/A/q/E its all the same
>> size(cm0_1)
ans =
4 1
all 1 to 3 (three sets, from three different datas: cm0_1,cm0_2,cm0_3 and cmq_1,cmq_2 and so on ) and maybe each letter, as they have 'cm' in common? (0,A,q,E) Thanks

2 commentaires

Roger Stafford
Roger Stafford le 11 Déc 2014
Modifié(e) : Roger Stafford le 11 Déc 2014
Your computations seem entirely normal, but could you please state your question in more detail. I don't understand what you are asking. In particular what is it you mean by "1 to 3 and maybe each letter? (0,A,q,E)" or "Is it possible to loop this" ?
Andil  Aboubakari
Andil Aboubakari le 11 Déc 2014
Modifié(e) : Andil Aboubakari le 11 Déc 2014
That code is only a third of what it should be. I have another two set which is exactly the same but all the 1 changes to 2 (second set) and then 3.
So I was asking if its possible to avoid the repetition and loop one line through all the four letters three times, roughly like this:
letter={'0';'A';'q';'E'}
for ii=1:3
for jj=1:numel(letter)
sigma(ii)cm(letter(jj))=std(cm(letter(jj)_(ii))
cm(letter(jj)(ii))=max(cm(letter(jj)_(ii))
cm(letter(jj)(ii))=min(cm(letter(jj)_(ii))
end
end
Obviously that not the right way for sure.

Connectez-vous pour commenter.

 Réponse acceptée

dpb
dpb le 11 Déc 2014

1 vote

...if its possible to avoid the repetition and loop one line through all the four letters...
"Possible", yes, but "there be dragons" that way...
for why and alternatives. I think newer doc has a discussion under eval of the topic as well. For this case probably the alternative of dynamically-named structure is good choice.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by