Plot dynamics of an ODE
古いコメントを表示
I have an ODE
and I need to plot
with respect to
and
varying p. Following is the sample plot required.

I managed to draw one plot for
and following is the sample code.
[xi,x] = meshgrid(0:0.001:1,0:0.002:1);
p =1
f2 = @(x,a,b) a*b*(x)./(b-2+x));
f1 = @(x,a,b) a*b*(1-x)./(2*b-x);
rs = @(x1,x2,a,b,p) x1.*f1(x,a,b) - p.*(1-x1).*f2(x,a,b);
figure
contour(x1,2,rs(x1,x2,1,2,1),[0 0]);
Next I added a loop for p as follows:
np = 10;
phi = linspace(0,1,np);
for p = 1:np
f2 = @(x,a,b) a*b*(x)./(b-2+x));
f1 = @(x,a,b) a*b*(1-x)./(2*b-x);
rs = @(x1,x2,a,b,p) x1.*f1(x,a,b) - p.*(1-x1).*f2(x,a,b);
R = rs(x1,x2,1,2, p(p));
contour(x1,x2,R);
hold on
end
hold off
But, instead of the required ourput of 10 plots in one graph, I get many plots (>10) in my output. Can someone please help me with this?
1 件のコメント
Cris LaPierre
2022 年 9 月 21 日
編集済み: Cris LaPierre
2022 年 9 月 21 日
You have not copied your code correctly here, as both examples do not run.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で General Applications についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


