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!!

Antworten (2)

Azzi Abdelmalek
Azzi Abdelmalek am 7 Jun. 2015

0 Stimmen

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 Kommentare

Inna
Inna am 7 Jun. 2015
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.
Azzi Abdelmalek
Azzi Abdelmalek am 7 Jun. 2015
Do you know how to read your Excell file? How your data are disposed in each sheet?
Image Analyst
Image Analyst am 7 Jun. 2015
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.
Inna
Inna am 7 Jun. 2015
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.
Azzi Abdelmalek
Azzi Abdelmalek am 7 Jun. 2015
You didn't answer my question, do you know how to read these data?
Inna
Inna am 7 Jun. 2015
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;
Muhammad Usman Saleem
Muhammad Usman Saleem am 7 Jun. 2015
Bearbeitet: Muhammad Usman Saleem am 7 Jun. 2015
(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
Inna
Inna am 7 Jun. 2015
I don't have the same x coordinates for each plot, so I will try what Star said. Thank you.

Melden Sie sich an, um zu kommentieren.

Star Strider
Star Strider am 7 Jun. 2015

0 Stimmen

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 Kommentare

Inna
Inna am 7 Jun. 2015
Thank you. I will try that.
Star Strider
Star Strider am 7 Jun. 2015
My pleasure!
Yuan Zhu
Yuan Zhu am 11 Okt. 2018
How to create that vector?
Star Strider
Star Strider am 11 Okt. 2018
Use the linspace function.
Catherine Mohs
Catherine Mohs am 4 Mär. 2019
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!

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Line Plots finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 7 Jun. 2015

Kommentiert:

am 4 Mär. 2019

Community Treasure Hunt

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

Start Hunting!

Translated by