plot multiple lines in one graph using data from sorted files

1 visualización (últimos 30 días)
Aster
Aster el 21 de Sept. de 2018
Respondida: Cris LaPierre el 21 de Sept. de 2018
I have a bunch of ascii files named 'Moo_1.dat','Moo_3,dat'... till 'Moo_300.dat'. within each file there are four columns, they don't have any labels/names on the top of each column. I wanna plot the third column of each files into one graph using for loop. How can I do that?

Respuestas (1)

Cris LaPierre
Cris LaPierre el 21 de Sept. de 2018
You are only asking about the plotting, so I assume you already know how to load your data. I use dlmread since that will read an ASCII-delimited file of numeric data into a matrix, which sounds like what you want to do.
How are you assigning this data to a variable? Is your loading of the data also occurring inside the for loop? I assume so. Otherwise, the loop would be unnecessary.
I'd probably do something like this:
filename = ["Moo_1.dat";"Moo_2.dat";"Moo_3.dat"];
...
for fnum = 1:length(filename)
Moo = dlmread(filename(fnum));
...
hold on
plot(Moo(:,3))
hold off
end
Look at the documentation of hold for more details and options.

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Help Center y File Exchange.

Productos


Versión

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by