Variable for a matrix

3 vues (au cours des 30 derniers jours)
Damith
Damith le 20 Mai 2014
Commenté : Damith le 20 Mai 2014
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.

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 20 Mai 2014
Modifié(e) : Azzi Abdelmalek le 20 Mai 2014
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 commentaires
Azzi Abdelmalek
Azzi Abdelmalek le 20 Mai 2014
Look at edited answer
Damith
Damith le 20 Mai 2014
Thanks. it worked.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by