Plotting two non linear equations in same graph

3 次查看(过去 30 天)
I have following two equations
y - ((t^8 - 8*t^7 + 36*t^6 - 96*t^5 + 146*t^4 - 88*t^3 - 116*t^2 + 144*t + 81)/(t^8 - 8*t^7 + 36*t^6 - 96*t^5 + 162*t^4 - 184*t^3 + 100*t^2 - 72*t + 162))==0,
t - ((sqrt(y)*(2/3)- (sqrt(1 - y)*((3 - 2*t)/(3(2-t)))))/(sqrt(y)*(((3-t^2))/(3*(2-t))) - sqrt(1-y)*(t/3))) ==0
but I can't seem to plot it. Here's what I did -
t= linspace(0,1);
y= linspace(0.5,1);
[X, Y] = meshgrid(t, y);
f1= @(t,y)(y - ((t^8 - 8*t^7 + 36*t^6 - 96*t^5 + 146*t^4 - 88*t^3 - 116*t^2 + 144*t + 81)/(t^8 - 8*t^7 + 36*t^6 - 96*t^5 + 162*t^4 - 184*t^3 + 100*t^2 - 72*t + 162)));
f2 = @(t,y)(t - ((sqrt(y)*(2/3)- (sqrt(1 - y)*((3 - 2*t)/(3*(2-t)))))/(sqrt(y)*(((3-t^2))/(3*(2-t))) - sqrt(1-y)*(t/3))));
surf(X, Y, f1(X, Y)) ;

采纳的回答

Torsten
Torsten 2023-7-28
t= linspace(0,1);
y= linspace(0.5,1);
[T, Y] = meshgrid(t, y);
f1 = @(t,y)(y - ((t.^8 - 8*t.^7 + 36*t.^6 - 96*t.^5 + 146*t.^4 - 88*t.^3 - 116*t.^2 + 144*t + 81)./(t.^8 - 8*t.^7 + 36*t.^6 - 96*t.^5 + 162*t.^4 - 184*t.^3 + 100*t.^2 - 72*t + 162)));
f2 = @(t,y)(t - ((sqrt(y)*(2/3)- (sqrt(1 - y).*((3 - 2*t)./(3*(2-t)))))./(sqrt(y).*(((3-t.^2))./(3*(2-t))) - sqrt(1-y).*(t/3))));
surf(T,Y,f1(T,Y))
hold on
surf(T,Y,f2(T,Y))
  14 个评论
Sabrina Garland
Sabrina Garland 2023-7-30
In the Attached graph, intersection happens at t=0.990099 and y= 1
Torsten
Torsten 2023-7-30
编辑:Torsten 2023-7-30
No. It happens at t = 1 and y = something below 1.
Or look again at the graphs here. t is abscissa and y is ordinate !
t = linspace(-3.5,3);
f1 = @(t)((t.^8 - 8*t.^7 + 36*t.^6 - 96*t.^5 + 146*t.^4 - 88*t.^3 - 116*t.^2 + 144*t + 81)./(t.^8 - 8*t.^7 + 36*t.^6 - 96*t.^5 + 162*t.^4 - 184*t.^3 + 100*t.^2 - 72*t + 162));
f2 = @(t,y)t - ((sqrt(y)*(2/3)- (sqrt(1 - y).*((3 - 2*t)./(3*(2-t)))))./(sqrt(y).*(((3-t.^2))./(3*(2-t))) - sqrt(1-y).*(t/3)));
plot(t,f1(t))
hold on
fimplicit(f2,[-3.5 3 0 1])
hold off
xlabel('t')
ylabel('y')

请先登录,再进行评论。

更多回答(1 个)

Voss
Voss 2023-7-28
Use element-wise operations (.^, ./, .*)
t= linspace(0,1);
y= linspace(0.5,1);
[X, Y] = meshgrid(t, y);
f1= @(t,y)(y - ((t.^8 - 8*t.^7 + 36*t.^6 - 96*t.^5 + 146*t.^4 - 88*t.^3 - 116*t.^2 + 144*t + 81)./(t.^8 - 8*t.^7 + 36*t.^6 - 96*t.^5 + 162*t.^4 - 184*t.^3 + 100*t.^2 - 72*t + 162)));
f2 = @(t,y)(t - ((sqrt(y)*(2/3)- (sqrt(1 - y).*((3 - 2*t)./(3*(2-t)))))./(sqrt(y).*(((3-t.^2))./(3*(2-t))) - sqrt(1-y).*(t/3))));
surf(X, Y, f1(X, Y)) ;

类别

Help CenterFile Exchange 中查找有关 General Applications 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by