How to plot Average of several plots( combined using copyobj) ?
古いコメントを表示
Hi Everyone, I have data sets of multiple subjects, and i plotted the desired output of each subject in separate plots. Then i wanted to compare them and plot in one figure, so i am using 'Copyobj' for that. It does the job. Now i want to plot the 'Average' of all the subject's output plots. Is it possible to do this when i have combined the separate plots (output of separate programs)?
Thanks
回答 (1 件)
dpb
2018 年 8 月 19 日
Not without using the data to compute the average, no...
But using copyobj to combine the plots is the hard way to go about creating the plot...just either
- Plot first subject
- Add values to running sum
- hold on % to add to existing plot
- Plot next subject
- Add values to running sum
- Repeat 4., 5. for rest of subjects
- Divide sum by N subjects
- Plot mean
Alternatively, read each subject data into array (say S) storing by column for the N subjects, compute
S(:,end+1)=mean(S,2); % put mean in last column
plot(S) % plot, including mean
Above plots against ordinal value; if is an X abscissa, use it as vector or array as well.
2 件のコメント
Joana
2018 年 8 月 19 日
dpb
2018 年 8 月 19 日
The first uses only a single dataset at a time plus the running sum; you don't give any hint of how the data are obtained/organized/etc. so not much to do for writing specific code but
d=dir('appropriatewildcard'); % get subject files
N=length(d); % how many are there
x=importdata(d(1).name); % read first
S=x; % save running sum
plot(x) % plot first
hold on % to add more
for i=2:N % iterate over rest
x=importdata((i).name);
plot(x)
S=S+x; % accumulate sum
end
S=S/N; % compute mean
plot(S) % add to plot
Add labels, etc., etc., etc., ... as desired
カテゴリ
ヘルプ センター および File Exchange で Graphics Performance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!