Time plotting in MATLAB
조회 수: 1 (최근 30일)
이전 댓글 표시
i tried to plot the time variation on X-axis but it showning today's date (Please, how can i format the x-axis to show only the time and not both time and date on the x-axis)? i do not want todays date (Jul 9,2020 to be showing on the x-axis)
Also how can i increase the number of points on x-axis to vary every on hour or 2 hours instead of 6 hours?
See the screenshot of the excel sheet & plot attached
%% Read different data sets1
% Read data sets for current1, voltage1, radiation1,time1,tem1,temp2;
% Create figure
figurea = figure(1);
% Create axes
axes1 = axes(figurea);
hold(axes1,'on');
% Create plot
plot(time,radiation1,'LineStyle','--','Color',[1 0 0]);
% Create ylabel
ylabel('Radiation','FontWeight','bold','FontName','Arial');
% Create xlabel
xlabel('TimeOfDay','FontWeight','bold','FontName','Arial');
% Create title
title('Electrical performance1');
legend('SOlarIrradiation');
Str={'Solar Variation/Time Graph', 'of LSC Device'};
txt1=text(10,3000,Str,'Color','blue','Fontsize',16);
box(axes1,'on');
xtickformat('HH:mm:ss');
댓글 수: 0
답변 (1개)
jonas
2020년 7월 9일
편집: jonas
2020년 7월 9일
You can delete the secondary label (undocumented property),
delete(ax.XAxis.SecondaryLabel)
...but I would just plot the data as duration class instead, so that the time is not associated with a date.
Assuming your data is in datetime format:
t = timeofday(time)
plot(t,radiation1,'LineStyle','--','Color',[1 0 0]);
Changing the ticks, assuming your data is in duration format:
ax = gca;
ax.XTick = hours(0):hours(2):hours(24);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!