Can i plot the mean of a number of graphs that are in the same plot

Réponses (2)

M = magic(5);
figure
hold on
plot(M)
plot(mean(M),'LineWidth',4)

4 commentaires

In this simple example how can i have one plot that it will be the mean of these plots...for i=1:1:5 x=1:100; y=i*sin(x); plot(x,y) hold on end
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.
it is plotAverage which do this, but what i have to do in the previous example plotAverage(???).
Do you mean that you are using this plotAverage function from the File Exchange?
If so, I don't know anything about that. But maybe it has instructions. Try typing
help plotAverage

Connectez-vous pour commenter.

Adam
Adam le 13 Nov 2014
Modifié(e) : Adam le 13 Nov 2014
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.

2 commentaires

it is plotAverage which do this, but what i have to do in the previous example plotAverage(???).
What is plotAverage?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Line Plots dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by