【问题标题】:Plot time series of different length in Matlab在 Matlab 中绘制不同长度的时间序列
【发布时间】:2016-06-23 20:05:33
【问题描述】:

我想使用 Matlab 绘制存储在 11933x5 双精度 (Data2) 中的五个索引的回报。问题在于,该系列的长度不同,这意味着对于五个索引中的四个,第一个数据点不可用。 我想这就是为什么下面的代码只绘制一个系列的原因

dates = Data(:,1);
MATLABdates = x2mdate(dates);

MSCI = Data(:,2);
SaP = Data(:,5);
BRIC = Data(:,6);
HFRX = Data(:,9);
LPX = Data(:,10);

Data2 = horzcat(MSCI,SaP, BRIC, HFRX, LPX);

datetext = datestr(MATLABdates); 
datetext = cellstr(datetext);

DataT = table(MSCI,SaP,BRIC,HFRX,LPX);
DataT.Properties.RowNames = datetext;

Series = DataT.Properties.VariableNames;

figure
plot(MATLABdates, ret2price(price2ret(Data2)))
datetick('x')
xlabel('Date')
ylabel('Index Value')
title ('Relative Daily Index Closings')
legend(Series, 'Location', 'NorthWest')

这是结果图:

缺少四个较短的系列。

有谁知道我必须做什么才能看到所有系列(其中一些只是稍后才开始?

非常感谢!

【问题讨论】:

    标签: matlab plot time-series missing-data


    【解决方案1】:

    你可以使用:

    hold on
    plot(x1,y1)
    plot(x2,y2)
    ....
    plot(nx,yn)
    hold off
    
    or simply
    plot(x1,y1,'r',x2,y2,'b',....xn,yn,'<line options>')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-01
      • 2018-04-04
      • 2018-08-03
      • 2018-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多