- 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
How to plot Average of several plots( combined using copyobj) ?
조회 수: 17 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (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
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
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!