How to apply the limits to a plots created in a for loop? And how to make it faster?

2 visualizaciones (últimos 30 días)
I have a series of files that I got in 5 minutes intervals from each other, and I would like to plot all of them together in a single plot.
To do so I wrote the following bit of code:
for x = 0:5:60
filename = ['file_', num2str(x), '.txt'];
sample = readH5file(filename); %programme written by a colleague that reads the h5 files that the data originally comes in
time_p = cell2mat(sample(:,1));
intensity_p = cell2mat(sample(:,2));
plot(time_p, intensity_p)
xlim([7 10])
hold on;
end
Besides taking a fair amount of time to plot the 12 graphs into a single one, the x-limit never seems to work and I always have to change the axis of my plot "manually" after on Edit - Axes Properties. How can I apply the limits I want to this plot?
Is it possible to make this any faster too?
  1 comentario
Mathieu NOE
Mathieu NOE el 17 de Feb. de 2022
hello
try with xlim([7 10]) after the for loop
also, if the data you retrieve is always same dimensions, store them inside an array (preallocate memory) and do the plot after the for loop and not inside
that woud make your code faster

Iniciar sesión para comentar.

Respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by