Plotting two non linear equations in same graph

3 views (last 30 days)
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)) ;

Accepted Answer

Torsten
Torsten on 28 Jul 2023
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 Comments
Sabrina Garland
Sabrina Garland on 30 Jul 2023
In the Attached graph, intersection happens at t=0.990099 and y= 1
Torsten
Torsten on 30 Jul 2023
Edited: Torsten on 30 Jul 2023
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')

Sign in to comment.

More Answers (1)

Voss
Voss on 28 Jul 2023
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)) ;

Categories

Find more on Computational Geometry in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!