What did i do wrong in this code when i calculate the average of all the run

3 ビュー (過去 30 日間)
I run 9 sets of data and try to take the average of 9 sets. I calculate the mean but it shows the mean equals to the last set of data (set 9). It does not calculate the mean at all. Li is a matrix 101 x 9
for nrun = 1:9
% Calculate each Li
Li(:, nrun) = ........
LMean= mean(Li(:,nrun),2)
end
Did I code it wrong? Please helps
Thanks
  2 件のコメント
Walter Roberson
Walter Roberson 2012 年 11 月 26 日
Please restore the question so that others may learn from it.
Randy Souza
Randy Souza 2012 年 11 月 29 日
I have restored the original text of this question.
Phong Pham, this question has a clear subject and an accepted answer, so it may be valuable to someone else in the future. If you have a good reason why it should be removed from MATLAB Answers, please flag the question, explain why it should be deleted, and an administrator or high-reputation contributor will consider deleting the question. Please do not simply edit your question away.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2012 年 11 月 26 日
You are overwriting LMean on each iteration through the loop.
You could delay the mean() call until after the loop, and then use
LMean - mean(Li,2);
This would be for calculating the 101 x 1 mean (mean of each point across the datasets.) If you were looking for the 1 x 9 mean (mean of each dataset) it would be
LMean = mean(Li);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by