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 comentarios

Roger Stafford
Roger Stafford el 11 de Dic. de 2014
Editada: Roger Stafford el 11 de Dic. de 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 el 11 de Dic. de 2014
Editada: Andil Aboubakari el 11 de Dic. de 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.

Iniciar sesión para comentar.

 Respuesta aceptada

dpb
dpb el 11 de Dic. de 2014

1 voto

...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.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 11 de Dic. de 2014

Editada:

el 15 de Dic. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by