Plot a my own created function

2 ビュー (過去 30 日間)
Matthias Bossenbroek
Matthias Bossenbroek 2019 年 5 月 17 日
回答済み: Rik 2019 年 5 月 17 日
Hi,
I would like to plot my function over the interval [0,2] however i keep on getting an empty graph.
So far i have used:
fplot(@(Lambda)Steady_State(Lambda))
ylim([0 200])
My function itself has the following code.
Cheers,
function Beta = Steady_State(Lambda)
P0 = exp(-Lambda)
P1 = Lambda*exp(-Lambda)
P2 = (Lambda^(2)*exp(-Lambda)/2)
P3 = (Lambda^(3)*exp(-Lambda)/6)
b_NN = [100; 85; 75; 65; 55; 50; 45; 40; 35; 33; 31; 29; 27; 25; 23; 21.5; 20; 18.5; 17; 16; 15]
bonusmalus_NN = [1-P0,P0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,;
1-P0,0,P0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
1-P0,0,0,P0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
1-P0,0,0,0,P0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
1-P0,0,0,0,0,P0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
1-P0,0,0,0,0,0,P0,0,0,0,0,0,0,0,0,0,0,0,0,0,0;
1-P0-P1,P1,0,0,0,0,0,P0,0,0,0,0,0,0,0,0,0,0,0,0,0;
1-P0-P1,0,P1,0,0,0,0,0,P0,0,0,0,0,0,0,0,0,0,0,0,0;
1-P0-P1,0,0,P1,0,0,0,0,0,P0,0,0,0,0,0,0,0,0,0,0,0;
1-P0-P1,0,0,0,P1,0,0,0,0,0,P0,0,0,0,0,0,0,0,0,0,0;
1-P0-P1,0,0,0,0,P1,0,0,0,0,0,P0,0,0,0,0,0,0,0,0,0;
1-P0-P1-P2,P2,0,0,0,0,P1,0,0,0,0,0,P0,0,0,0,0,0,0,0,0;
1-P0-P1-P2,0,P2,0,0,0,0,P1,0,0,0,0,0,P0,0,0,0,0,0,0,0;
1-P0-P1-P2,0,0,P2,0,0,0,0,P1,0,0,0,0,0,P0,0,0,0,0,0,0;
1-P0-P1-P2,0,0,0,P2,0,0,0,0,P1,0,0,0,0,0,P0,0,0,0,0,0;
1-P0-P1-P2,0,0,0,0,P2,0,0,0,0,P1,0,0,0,0,0,P0,0,0,0,0;
1-P0-P1-P2-P3,P3,0,0,0,0,P2,0,0,0,0,P1,0,0,0,0,0,P0,0,0,0;
1-P0-P1-P2-P3,0,P3,0,0,0,0,P2,0,0,0,0,P1,0,0,0,0,0,P0,0,0;
1-P0-P1-P2-P3,0,0,P3,0,0,0,0,P2,0,0,0,0,P1,0,0,0,0,0,P0,0;
1-P0-P1-P2-P3,0,0,0,P3,0,0,0,0,P2,0,0,0,0,P1,0,0,0,0,0,P0;
1-P0-P1-P2-P3,0,0,0,0,P3,0,0,0,0,P2,0,0,0,0,P1,0,0,0,0,P0]
[V,A] = eig(bonusmalus_NN)
V_inv = inv(V)
p_lim = V*A^10000000*V_inv
p_lim = p_lim(1,:)
Beta = p_lim * b_NN
end
  2 件のコメント
KSSV
KSSV 2019 年 5 月 17 日
What is Lambda value?
Matthias Bossenbroek
Matthias Bossenbroek 2019 年 5 月 17 日
i would like to have a graph with lambda on the x-axis and Beta on the y-axis.
And Lambda should run from 0 to 2

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

採用された回答

Rik
Rik 2019 年 5 月 17 日
Your output is sometimes complex. You should fix this in your function, but you can also apply a quick fix here:
fplot(@(Lambda)abs(Steady_State(Lambda)))
ylim([0 200])
Ideally you should also make your function support vectorized inputs and deal with all the warnings (and suppress outputs by adding semicolons).

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by