Set x axis into hour

조회 수: 7 (최근 30일)
Luis Meneses
Luis Meneses 2015년 4월 18일
댓글: Star Strider 2015년 4월 21일
Hi,
I have a table with 2 columns: 1st column is Hour, and the other is other values. So, I want to make a plot with some values on the y axis, and the x axis will be time (hours). I want to start it from 11:00 PM (4/4/2015) until 9:00 PM (5/4/2015).
Can anyone help me?
Thanks :)
  댓글 수: 2
pfb
pfb 2015년 4월 18일
not very clear. Is this a problem of tick labels? If this is the case, take a look at axes properties, in particular tick values and labels.
Or do you need to convert dates into numerical values? In that case you might need the "datenum" and "datestr" functions
Luis Meneses
Luis Meneses 2015년 4월 21일
My table have 2 columns and 12 lines. On the first column i have the values of time: 11, 13, 15, 17, 19, 21, 23, 1, 3, 5, 7, 9. I need to make a plot that the x axis will de time, and i want to display on this order: 1, 13, 15, 17, 19, 21, 23, 1, 3, 5, 7, 9.
Can you help me?

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2015년 4월 21일
This is one possibility:
x = 1:24; % Create Data
y = randi([2 4], 1, length(x)); % Create Data
figure(1)
plot(x, y)
set(gca, 'XTick', [1:2:24], 'XTickLabel', rem([1:2:24]+10,24))
axis([1 23 0 5])
xlabel('Time (Hr)')
  댓글 수: 2
Luis Meneses
Luis Meneses 2015년 4월 21일
thank you so much :D
Star Strider
Star Strider 2015년 4월 21일
My pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by