- 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) ?
26 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
dpb
le 19 Août 2018
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 commentaires
dpb
le 19 Août 2018
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
Voir également
Catégories
En savoir plus sur Annotations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!