Hi,
I have to find mean from Trans1WW to Trans39WW. So, how can i make a variable so that I can include in a for loop.
St1_WW_avg=mean(Trans1WW);
Thanks.

 Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 20 de Mayo de 2014
Editada: Azzi Abdelmalek el 20 de Mayo de 2014

0 votos

for k=1:39
eval(sprintf('St1_WW_avg(%d)=mean(Trans%dWW)',k,k));
end
You shouldn't use all these variables, it's better to used one cell array containing all your variables.Look at

3 comentarios

Damith
Damith el 20 de Mayo de 2014
Thanks Azzi. I copied and pasted what you written and it does not work. Any idea?
Azzi Abdelmalek
Azzi Abdelmalek el 20 de Mayo de 2014
Look at edited answer
Damith
Damith el 20 de Mayo de 2014
Thanks. it worked.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Preguntada:

el 20 de Mayo de 2014

Comentada:

el 20 de Mayo de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by