필터 지우기
필터 지우기

How to plot Average of several plots( combined using copyobj) ?

조회 수: 30 (최근 30일)
Joana
Joana 2018년 8월 19일
댓글: dpb 2018년 8월 19일
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
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
  1. Plot first subject
  2. Add values to running sum
  3. hold on % to add to existing plot
  4. Plot next subject
  5. Add values to running sum
  6. Repeat 4., 5. for rest of subjects
  7. Divide sum by N subjects
  8. 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
Joana 2018년 8월 19일
Hi Yes i had this idea, but the data is in GB, so i can't hold on to load the data from 10 subjects and then add it in total. So is there any other possible way.?
dpb
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 CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by