How to properly import data from excel documents and graph them?

4 views (last 30 days)
I have about 27 of these types of excel files from a wind tunnel experiment i need to put in my code. The one circled in red will be one variable and the ones circled in blue will be another. Every time i try to import the information into matlab i get this error.
how do i fix it; also how would you say graph a graph with x as the x-axis and three of the Cp0_...(30,90,40 f/s) values as different lines in the y-axis.
  4 Comments
me
me on 16 Sep 2015
Edited: me on 16 Sep 2015
I converted the files and they are opening up now. Thank you.
But about my second question how wold I graph three or more of the files(the green part in each file) onto one figure. with x axis being the function named x.
dpb
dpb on 16 Sep 2015
Read the first file and plot it. After done, execute
hold on
to retain the axes rather than overplot.
Then iterate over the remaining files ( dir is very useful here). Just keep plotting and voila! you're done when the loop ends.
Or, alternatively, since there's not much data in terms of size, read all the files in a loop storing the additional values as additional columns in a data array then plot all at the end. Only deal here is that if there aren't the same number of observations in each data set but that adds only a little extra complexity to the details.

Sign in to comment.

Answers (1)

Kirby Fears
Kirby Fears on 16 Sep 2015
Edited: Kirby Fears on 16 Sep 2015
To summarize all the comments, xlsread won't work on a file improperly saved in xls format, so you have to re-save them properly (which you did already, great).
Once you've read the files you want and identified the numerical vector's you're trying to plot, you can simply plot them all at once using this syntax:
plot(X1,Y1,LineSpec,...,Xn,Yn,Linespec);
X is the vector of x-axis values and Y is the vector of values you circled in the picture. You don't need to specify LineSpec if you don't want to.
As dpb pointed out, you could just plot one pair at a time like this:
plot(X1,Y1,LineSpec);
hold on;
plot(X2,Y2,LineSpec):
etc...

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!