【问题标题】:Repeating numbers in x-axis matlab plotx轴matlab图中的重复数字
【发布时间】:2015-11-02 21:25:24
【问题描述】:
IEF % is a matrix have negative and positive values (1441 X 1)
T=linspace(0,24,1441);
figure,
plot(T,IEF)
grid on
set(gca,'xticklabel', 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24)

这段代码给了我一个 x 轴序列从 0 到 24(小时)的数字,但数据是五天,所以我需要在 X 轴上重复 0 到 24 五次。

我该怎么做?

【问题讨论】:

    标签: matlab data-analysis


    【解决方案1】:

    我建议不要绘制 24*5=120 的数字,因为那样会弄乱你的情节。要么让 MATLAB 使用默认设置,要么设置如下:

    set(gca,'xticklabel', 0:24) %// for 24 hours, shorter of what you had above
    set(gca,'xticklabel', 0:120) %// for 5 days
    set(gca,'xticklabel', 0:6:120) %// for 5 days in steps of 6 hours
    

    如果您想使用实际的 24 小时而不是 0 到 120 小时,请使用 repmat

    TimeHour = 0:6:24;
    Time24Hour = 0:24;
    TICKLABEL = repmat(TimeHour,1,5); %// change the 5 to how many days you want
    TICKLABEL24 = repmat(Time24Hour,1,5); %// utilises 0:24 five times
    set(gca,'xticklabel', TICKLABEL)
    set(gca,'xticklabel', TICKLABEL24)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多