Variable for a matrix

4 次查看(过去 30 天)
Damith
Damith 2014-5-20
评论: Damith 2014-5-20
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.

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2014-5-20
编辑:Azzi Abdelmalek 2014-5-20
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 个评论
Azzi Abdelmalek
Azzi Abdelmalek 2014-5-20
Look at edited answer
Damith
Damith 2014-5-20
Thanks. it worked.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by