average curve of 10 plots

Hi, I have 10 plots on the same figure and I need to plot an average curve of these plots. I have all the data in an excel file. I need the average plot to be on a separate figure. Could anyone help me with that? Thank you!!

Answers (2)

Read the data from your Excell file, I suppose you have a nx10 matrix
M=rand(20,10)% Example
A=mean(M,2)
plot(A)

9 Comments

Thank you for your answer. Actually I don't have a nx10 matrix but an excel file with 10 different sheets. It is a time series of a value and the time points are not the same for all matrixes, that's why I have different matrixes.
Do you know how to read your Excell file? How your data are disposed in each sheet?
Inna, did you notice that there is an xlsread() function and it can take the sheet name or sheet number as an input? Look it up in the help.
My data contain time series and I don't have the same time values for each matrix. That's why I don't have a nx10 matrix.
You didn't answer my question, do you know how to read these data?
Yes, I know how to read excel files. I have plotted my data. I have 10 plots on a figure. I just need to plot the average of these 10 plots.
Does every plot have the same x coordinates? If not, see Star's answer. If so, just average and plot. Assuming your data is called d1, d2, d3, etc. and does have common/shared x values, then:
dMean = 0.1*(d1+d2+d3+d4+d5+d6+d7+d8+d9+d10);
plot(dMean, 'b*-', 'LineWidth', 2, 'MarkerSize', 8);
grid on;
(1)i recomend that takes means of values in excel and then plot. (2) If you want best fit line of 10 plot use regression. But firstly makes all plots on one by using hold command. @Image please guide me about my question at http://www.mathworks.com/matlabcentral/answers/222131-how-to-make-a-function-whose-first-input-argument-is-a-cell-vector-row-or-column-of-strings-and-wh
I don't have the same x coordinates for each plot, so I will try what Star said. Thank you.

Sign in to comment.

Star Strider
Star Strider on 7 Jun 2015
I would create a common, regularly-spaced, time vector that spans the shortest time of your files (so you don’t have to extrapolate), and then use it with the interp1 function to create a second set of data for each file, now with values for the same time base. Then you should be able to average them.

5 Comments

Thank you. I will try that.
My pleasure!
How to create that vector?
Use the linspace function.
Start Strider, could you please show us an example on how to do this? I think I know what you are trying to do, but I'm not entirely sure of the syntax. Thank you!

Sign in to comment.

Categories

Asked:

on 7 Jun 2015

Commented:

on 4 Mar 2019

Community Treasure Hunt

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

Start Hunting!