Graphing two parametric functions in terms of x

2 ビュー (過去 30 日間)
Nicolas Heumann
Nicolas Heumann 2019 年 6 月 16 日
コメント済み: Nicolas Heumann 2019 年 6 月 17 日
I am learning from Paul Wilmott's Introduction to quantitative Finance, and I have ran into a problem while trying to solve one of the suggested exercises:
I am trying to plot both of the following parametric functions in a single graph:
and
I have tried the following code:
w=linspace(0,1);
mu= 0.1*w+0.14*(1-w);
sigma = (0.12^2)*w.^2+0.4*0.12*0.2*2*w.*(1-w)+(0.2^2)*(1-w).^2;
plot(sigma,mu);
xlabel('mu'),ylabel('sigma')
title('risk vs return')
But I get the following graph (note that sigma is the risk and mu the return)
grafico1.PNG
When I should be getting this:
grafico2.PNG
Why does this happen? I have tried altering the range of w but I still get nothing close to that graph. The equations that I am graphing are these, and I believe that I have written them correctly
eqs.PNG
  1 件のコメント
dpb
dpb 2019 年 6 月 16 日
ML auto-ranges the axes to fit the range of the data...use
ylim([0 0.15])
or whatever other upper limit you choose...

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

採用された回答

John D'Errico
John D'Errico 2019 年 6 月 17 日
編集済み: John D'Errico 2019 年 6 月 17 日
You got exactly the correct thing. You just need to look carefully at the y axis labels on the two plots.
Just add this line after the plot.
axis([.01 .04 0 0.14])
Or, you could use the ylim function.
ylim([0 0.14])
Or, you can edit the graphic directly.
H = gca;
H.YLim = [0 0.14];
A plot can look very different when you change the axis scaling. (This is an important point as I recall from the book "How To Lie With Statistics".)
  1 件のコメント
Nicolas Heumann
Nicolas Heumann 2019 年 6 月 17 日
Wow, that worked like a charm! I will check out that book, too, thank you very much!

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by