How to apply the limits to a plots created in a for loop? And how to make it faster?
조회 수: 2 (최근 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
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 Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!