Reputation: 139
Using Matlab I would like to plot the returns of five indices stored in a 11933x5 double (Data2). The problem ist, that the series are of different length, meaning for four of the five indices the first data points are not available. I guess this is why the following code only plots one series
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')
the four shorter series are missing.
Does anyone know what I have to do to see all of the series (some of them just starting a little bit later?
Thanks a lot!
Upvotes: 0
Views: 632
Reputation: 4865
you can use:
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>')
Upvotes: 1