フィルターのクリア

How do I plot mean value of many vectors?

17 ビュー (過去 30 日間)
Edvin Ahmetovic
Edvin Ahmetovic 2015 年 5 月 15 日
回答済み: Jan 2015 年 5 月 15 日
Hi, how do I plot mean value of many vectors if the vectors is:
A = [0.081291416701925745, 0.14122419702054573, 0.27766822860596385, 0.380279607387342, 0.54696467005974858, 0.62106188150998232]
B = [0.09500440211107572, 0.20768728979483142, 0.28754282325812419, 0.39277042574339854, 0.50507788272174581 0.58958996553175536]
C = [0.15915833966016121, 0.167108268948393, 0.27719960333431254, 0.40183364422854823, 0.47372736284207673, 0.62400570035234515] ... and so on.
Thanks!
  1 件のコメント
Jan
Jan 2015 年 5 月 15 日
This is not "a vector", but "three vectors". So what does "and so on" mean exactly? This detail matters and we cannot guess it.

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

回答 (2 件)

Jan
Jan 2015 年 5 月 15 日
If the core of the question is how a list of variables can be processed, the answer is:
Don't do this. Do not store a bunch of variables with different names, but store the data in an array. If all vectors have the same length, a matrix is efficient, otherwise a cell array:
M = [0.081291416701925745, 0.14122419702054573, 0.27766822860596385, ...
0.380279607387342, 0.54696467005974858, 0.62106188150998232; ...
0.09500440211107572, 0.20768728979483142, 0.28754282325812419, ...
0.39277042574339854, 0.50507788272174581 0.58958996553175536; ...
0.15915833966016121, 0.167108268948393, 0.27719960333431254, ...
0.40183364422854823, 0.47372736284207673, 0.62400570035234515];
Then you can calculate the mean directly:
MeanM = mean(M, 2);
With a cell:
A{1} = [0.081291416701925745, 0.14122419702054573, 0.27766822860596385, ...
0.380279607387342, 0.54696467005974858, 0.62106188150998232];
A{2} = [0.09500440211107572, 0.20768728979483142, 0.28754282325812419, ...
0.39277042574339854, 0.50507788272174581 0.58958996553175536];
A{3} = [0.15915833966016121, 0.167108268948393, 0.27719960333431254, ...
0.40183364422854823, 0.47372736284207673, 0.62400570035234515];
MeanA = cell(size(A));
for k = 1:numel(A)
MeanA{k} = mean(A{k});
end

Mahdiyar
Mahdiyar 2015 年 5 月 15 日
Hi The question is not complete because the mentioned vectors are a one row matrix and the average of this matrix is a number. So why you want to plot a point??
If you want to find the average value of some row matrices , you can do the following code. Note that in this case the matrices should be the same size, otherwise you have to calculate the average value of each of them separately.
Average = mean(transpose([A; B; C]));
  1 件のコメント
Jan
Jan 2015 年 5 月 15 日
Instead of transposing you can tell mean() the dimension to operate on:
mean([A; B; C], 2)

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

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by