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

1 次查看(过去 30 天)
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 个评论
Mathieu NOE
Mathieu NOE 2022-2-17
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

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by