how to average multiple function runs together

3 ビュー (過去 30 日間)
Pamela Stein
Pamela Stein 2014 年 3 月 17 日
回答済み: Pamela Stein 2014 年 3 月 17 日
Hi,
I have a function [runx] with an output that is a 11x256 matrix.
I would like to run this function 500 times. And generate a matrix with all the elements' averages. Sum(x) adds the elements in the same matrix together. It's not what I want.
For example:
run #1: [1 3 5; 4 6 7], run #2: [0 0 0; 1 1 1], run #3: [3 4 6; 0 1 2]
The operation that I would like to do is:
first row is [ (1+0+3)/3 (3+0+4)/3 (5+0 +6)/3] second row is [ (4+1+0)/3 (6+1+1)/2 (7+1+2)/3]
Final result: [4/3 7/3 11/3; 5/3 8/3 10/3]
Please help. Thank you.

採用された回答

Pamela Stein
Pamela Stein 2014 年 3 月 17 日
A long way about doing it, but I got it to work.
jj = 500; [wxgen]=runx;
m = wxgen;
for i=1:jj-1 [wxgen]=runx; m = m+wxgen; end
meantwxgen = l./jj

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2014 年 3 月 17 日
mean( cat(3, run1, run2, run3), 3)
  1 件のコメント
Pamela Stein
Pamela Stein 2014 年 3 月 17 日
Since I want to generate my function 500 times, there will be five-hundred 11x256 matrices. Am I typing run1, run2,... run500? My run code so far is (wxgen is a 11x256 matrix output of my function runx).
for i = 1:500; [wxgen] = runx
???? end

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

カテゴリ

Help Center および File ExchangeData Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by