フィルターのクリア

How to combine multiple arrays and do plotting showing min ave max?

1 回表示 (過去 30 日間)
Phoenix
Phoenix 2020 年 5 月 9 日
コメント済み: Ameer Hamza 2020 年 5 月 10 日
Hi,
I have Variable A (1000x1 cell), and inside that cell is is 1000 samples of numbers (8760x21 double -- screenshot below). How can I generate an 8760x21 matrix on each of the following:
  1. Minimum -- min of all the 1000 samples
  2. Average -- average of all the 1000 samples
  3. Maximum -- max of all the 1000 samples
Further, how to have a plot showing uncertainty in each 21 parameters (columns). By uncertainty, I want to plot in x-axis the number of hours (1 - 8760) and the correponding min ave max of parameter 1 (column 1) on the y-axis, then eventually repeat it for parameter 2 (column 2) so on and so forth. Thank you.

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 5 月 9 日
編集済み: Ameer Hamza 2020 年 5 月 9 日
Try this code
% generate sample data
A = cell(1,1000);
for i=1:numel(A)
A{i} = rand(8760, 21);
end
% generate min, max, and average values
M = cat(3, A{:});
result(:,:,1) = max(M, [], 3); % max value
result(:,:,2) = min(M, [], 3); % min value
result(:,:,3) = mean(M, 3); % average value
I guess you want to plot min, max, and average value for each column on a seperate axes. Run the following code to plot the data
figure('WindowState', 'maximized');
ax = axes();
tiledlayout('flow');
for i=1:size(result,2)
ax = nexttile;
hold(ax);
for j=1:size(result,3)
plot(result(:,i,j));
end
title(sprintf('Colums: %d', i))
xlabel('days');
ylabel('values');
legend({'max', 'min', 'average'});
end
  9 件のコメント
Phoenix
Phoenix 2020 年 5 月 10 日
Oh, I was able to do it. But my code was a bit 'manual' so it went super long whenever I add new col. Now working on adding the secondary axis. Thanks for your help, Ameer.
Ameer Hamza
Ameer Hamza 2020 年 5 月 10 日
Is the problem solved? Can you show what you have tried and how you wan to improve it?

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by