How to start a plot at specific point

I would like to plot this graph which has two matrices held on, but I want both of them to start at the point (0,100) rather than start at the first point for each matrix. Below is the code that I've used
%%Plot a Graph with equally weighted stocks
figure1= plot(CumRet);
hold on
plot(CumBench)
title ('Equally Weighted Portfolio v Benchmark')
xlabel('Days Held')
ylabel('Portfolio Balance (in $Mn)')
legend ('Portfolio','Benchmark')

3 件のコメント

Geoff Hayes
Geoff Hayes 2017 年 2 月 16 日
Yuri - please describe CumRet and CumBench. Are they matrices with two columns and n rows? Or the opposite? Is there a point (0,100) in either or are you trying to find the closest point to (0,100)? Perhaps attach the data for both (as mat file(s)) to this question.
Yuri Karev
Yuri Karev 2017 年 2 月 16 日
編集済み: Image Analyst 2017 年 2 月 16 日
Hey Geoff, both are matrices that are 1 x 30 and the point for both would be to start at day 0 with 100 dollars and the next point for both should be the first return that they have. Here is my CumRet code as reference
for j = 1:size(Ret,1)
for i=1:length(symbols)
portret(j,i)=w(i,1)*table2array(Return(j,i+1)); %Gonzalo helped code this
end
PortfolioRet(:,j) = sum(portret(j,:)); %this sums all the returns from stocks for the day
end
CumRet= 100*(1+cumsum(PortfolioRet));
Geoff Hayes
Geoff Hayes 2017 年 2 月 21 日
Yuri - so of the thirty elements in the 1x30, which one corresponds to day zero and 100 dollars? Or are you trying to modify the above code so that whatever starts with 100 dollars? Please comment on what your above code is attempting to do.

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

タグ

質問済み:

2017 年 2 月 16 日

コメント済み:

2017 年 2 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by