绘制连续线

问题描述 投票:-1回答:1

我怎样才能得到此图在MATLAB?这是屏障B=120,罢工K=100落魄看涨期权的收益。我应该以某种方式在一个画面结合两个图表?

enter image description here

matlab plot line visualization matlab-figure
1个回答
2
投票

您可以以不同的方式做到这一点。这里有两个:

Option 1:

function q54615569(B, K)
y = @(x)(x>=B).*(x-K);
x = 0:2*K;
figure(); plot(x, y(x));
xlabel('S(T)');

enter image description here

Option 2:

function q54615569(B, K)
y = @(x)x-K;
x = 0:2*K;
figure(); hL = plot( x(x<=B), 0.*x(x<=B), x(x>=B), y(x(x>=B)) );
set(hL, 'Color', lines(1), 'Linestyle', 'none', 'Marker','o','MarkerSize', 2,...
  'MarkerFaceColor', lines(1));
xlabel('S(T)');

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.