Azzera filtri
Azzera filtri

Variable for a matrix

4 visualizzazioni (ultimi 30 giorni)
Damith
Damith il 20 Mag 2014
Commentato: Damith il 20 Mag 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.

Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 20 Mag 2014
Modificato: Azzi Abdelmalek il 20 Mag 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 Commenti
Azzi Abdelmalek
Azzi Abdelmalek il 20 Mag 2014
Look at edited answer
Damith
Damith il 20 Mag 2014
Thanks. it worked.

Accedi per commentare.

Più risposte (0)

Categorie

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

Community Treasure Hunt

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

Start Hunting!

Translated by