How to plot this implicit function

I need a beta vs eps plot of the curve t^2-d. The expression of t and d depends on x, y where x, y depend on beta. Please help. Ranges of beta and eps are both equal to 0:.01:1,
alpha=1.5; A=0.0207; gamma=0.25;
x=@(beta) (beta-alpha*(beta-gamma)+sqrt((beta-alpha*(beta-gamma)).^2+4*alpha*beta*gamma*A))./(2*beta);
y=@(beta) x.*(1-x).*beta/gamma;
t=@(beta,eps) -x+x.*y.*(alpha-eps*beta)./((A+x+y).^2);
d=@(beta,eps) eps*beta.*x.*y.*(x.^2+(A+x).*x+A*alpha)./((A+x+y).^3);
F=@(beta,eps) (t.^2-d);
figure
ezplot(F,[0,1,0,1]);

9 件のコメント

darova
darova 2019 年 9 月 8 日
I don't see here eps
x=@(beta,eps) (beta-alpha*(beta-gamma)+sqrt((beta-alpha*(beta-gamma)).^2+4*alpha*beta*gamma*A))./(2*beta);
What is x? Where is eps?
y=@(beta,eps) x.*(1-x).*beta/gamma;
Atom
Atom 2019 年 9 月 8 日
編集済み: Atom 2019 年 9 月 8 日
t and d depend on x and y.
x depends on beta. I have written x=@(beta,eps) although x does not have eps. Should I only write x=@(beta)? Although I am not getting the plot.
Edited...
darova
darova 2019 年 9 月 8 日
Sorry didn't notice that. You should write input arguments for your function all the time
f1 = @(x,y) x + y;
f2 = @(x,y) f1 + 2*x;
% f2 = @(x,y) f1(x,y) + 2*x; % should be
f2(1,1)
Atom
Atom 2019 年 9 月 8 日
Not clear... would you please see my problem... y depends on x, & etc
darova
darova 2019 年 9 月 8 日
x=@(beta) (beta-alpha*(beta-gamma)+sqrt((beta-alpha*(beta-gamma)).^2+4*alpha*beta*gamma*A))./(2*beta);
y=@(beta) x.*(1-x).*beta/gamma;
has to be
x=@(beta) (beta-alpha*(beta-gamma)+sqrt((beta-alpha*(beta-gamma)).^2+4*alpha*beta*gamma*A))./(2*beta);
y=@(beta) x(beta).*(1-x(beta)).*beta/gamma;
Atom
Atom 2019 年 9 月 8 日
編集済み: Atom 2019 年 9 月 8 日
I have modified the code as per your suggestion but getting some warning
alpha=1.5; A=0.0207; gamma=0.25;
syms x y t d fun2
beta=0:.0001:10;
x=@(beta) (beta-alpha*(beta-gamma)+sqrt((beta-alpha*(beta-gamma)).^2+4*alpha*beta*gamma*A))./(2*beta);
y=@(beta) x(beta).*(1-x(beta)).*beta/gamma;
t=@(beta,eps)-x(beta)+x(beta).*y(beta).*(alpha-eps*beta)./((A+x(beta)+y(beta)).^2);
d=@(beta,eps) eps*beta.*x(beta).*y(beta).*(x(beta).^2+(A+x(beta)).*x(beta)+A*alpha)./((A+x(beta)+y(beta)).^3);
fun2=@(beta,eps) (t(beta,eps)*t(beta,eps)-d(beta,eps));
figure
ezplot(fun2,[0,1,0,1])
% Please see this.
darova
darova 2019 年 9 月 8 日
Vectorizing
22Capture.PNG
Forgot the dot
12Capture.PNG
Why not use .^2?
fun2 = @(beta,eps) t(beta,eps).^2 - d(beta,eps);
Atom
Atom 2019 年 9 月 8 日
Inserted dot. still warning exists.
Warning: Function failed to evaluate on array inputs; vectorizing the function may speed up its evaluation and avoid the
need to loop over array elements.
> In ezplotfeval (line 56)
In ezplot>ezimplicit (line 257)
In ezplot (line 153)
In untitled1 (line 10)
darova
darova 2019 年 9 月 8 日
Works for me
export_fig_out.png

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

 採用された回答

darova
darova 2019 年 9 月 8 日

0 投票

Try symbolic expression
clc,clear
alpha=1.5; A=0.0207; gamma=0.25;
syms beta eps
x = (beta-alpha*(beta-gamma)+sqrt((beta-alpha*(beta-gamma)).^2+4*alpha*beta*gamma*A))./(2*beta);
y = x.*(1-x).*beta/gamma;
t = -x+x.*y.*(alpha-eps*beta)./((A+x+y).^2);
d = eps*beta.*x.*y.*(x.^2+(A+x).*x+A*alpha)./((A+x+y).^3);
% convert symbolic expression to function handle
F = matlabFunction(t.^2 - d,'vars',[beta eps]);
ezplot(F,[0,1,0,1]);

2 件のコメント

darova
darova 2019 年 9 月 8 日
Can be used without bit-wise ./ and .* (just / and *)
madhan ravi
madhan ravi 2019 年 9 月 8 日
There are in-built functions under the name alpha() , beta() , gamma() , eps().

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

その他の回答 (0 件)

カテゴリ

タグ

質問済み:

2019 年 9 月 8 日

コメント済み:

2019 年 9 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by