Borrar filtros
Borrar filtros

Plotting two non linear equations in same graph

3 visualizaciones (últimos 30 días)
Sabrina Garland
Sabrina Garland el 28 de Jul. de 2023
Editada: Torsten el 30 de Jul. de 2023
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)) ;

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (1)

Voss
Voss el 28 de Jul. de 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)) ;

Categorías

Más información sobre General Applications en Help Center y File Exchange.

Productos


Versión

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by