Variable for a matrix

1 view (last 30 days)
Damith
Damith on 20 May 2014
Commented: Damith on 20 May 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.

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 20 May 2014
Edited: Azzi Abdelmalek on 20 May 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 Comments
Azzi Abdelmalek
Azzi Abdelmalek on 20 May 2014
Look at edited answer
Damith
Damith on 20 May 2014
Thanks. it worked.

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!