time on x axis
조회 수: 1 (최근 30일)
이전 댓글 표시
I have the following code
fid = fopen('file.txt','rt');
X = textscan(fid,'%s%s%f%s%s%s%f%f%f%f%s%s%s%s',...
'HeaderLines',7);
fclose(fid);
time= X{1}; ydata=X{10};
start=time(1,1); done=time(end);%retrieve start and end time
startDate = datenum(start);
endDate = datenum(done);
xData = linspace(startDate,endDate,...
length(time));%./(length(time)./15)));
plot(xData,ydata)
set(gca,'XTick',xData)
datetick('x','HH:MM:SS','keepticks')
grid on
This plots some data against time data that I take from a huge data file. The problem is that there are so many plot points that the date data on the x axis is all jumbled together. How do I add something to the code to make only like every 10 minutes of time data be displayed instead of displaying every second and having it all jumbled together?
댓글 수: 0
채택된 답변
Fangjun Jiang
2011년 11월 21일
can you try to skip the "set(gca,'XTick',xData)" line and use the default xtick set by plot()?
댓글 수: 0
추가 답변 (1개)
Alex
2011년 11월 21일
shorter_data = resample(xData, down_size_factor)
down_size_factor should be a whole number. Using 2 will skip every other data point and leave you with half the original data points.
댓글 수: 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!