Effacer les filtres
Effacer les filtres

Plotting two non linear equations in same graph

3 vues (au cours des 30 derniers jours)
Sabrina Garland
Sabrina Garland le 28 Juil 2023
Modifié(e) : Torsten le 30 Juil 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)) ;

Réponse acceptée

Torsten
Torsten le 28 Juil 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 commentaires
Sabrina Garland
Sabrina Garland le 30 Juil 2023
In the Attached graph, intersection happens at t=0.990099 and y= 1
Torsten
Torsten le 30 Juil 2023
Modifié(e) : Torsten le 30 Juil 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')

Connectez-vous pour commenter.

Plus de réponses (1)

Voss
Voss le 28 Juil 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)) ;

Catégories

En savoir plus sur General Applications dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by