How to properly import data from excel documents and graph them?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/149131/image.png)
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/149132/image.png)
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 comentarios
dpb
el 16 de Sept. de 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.
Respuestas (1)
Kirby Fears
el 16 de Sept. de 2015
Editada: Kirby Fears
el 16 de Sept. de 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...
0 comentarios
Ver también
Categorías
Más información sobre Line Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!