Can i plot the mean of a number of graphs that are in the same plot
Show older comments
Hello, In the same figure i have many different graphs. Is there a way to take the mean plot of those
Answers (2)
the cyclist
on 13 Nov 2014
M = magic(5);
figure
hold on
plot(M)
plot(mean(M),'LineWidth',4)
4 Comments
Pantelis Saviolakis
on 13 Nov 2014
Adam
on 13 Nov 2014
Just take the mean of the data and plot that. The fact you have plotted the data is independent of being able to take the mean of the input data and plot that, other than by the use of
hold on
to ensure you don't overwrite your other plots, which you have anyway.
Pantelis Saviolakis
on 13 Nov 2014
the cyclist
on 13 Nov 2014
If so, I don't know anything about that. But maybe it has instructions. Try typing
help plotAverage
How did your graphs get there?
Ideally keep the handles to the line plots (I assume they are line plots) when you plot them so you can access them again later without having to find axes children.
Even better just keep all the data you originally plotted, take its mean and add it to the same plot as all the rest using whatever properties of Line you want to make it stand out.
If you don't have the data, only the plots then you will have to extract the 'XData' and 'YData' properties of your line objects to do the maths on.
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!