Effacer les filtres
Effacer les filtres

How can I solve this implicit function in MatLab?

10 vues (au cours des 30 derniers jours)
João Pedro
João Pedro le 10 Mai 2024
Commenté : João Pedro le 11 Mai 2024
I have the implicit function f1 = @(x,y) a*log(y) - alpha*y + b*log(x) - beta*x - k1 and with the fimplicit command it is possible to plot a graph. I need to create an output with the x and y values ​​used to plot this graph. Is there a way to obtain these values? a, alpha, b, beta and k1 are known.

Réponse acceptée

John D'Errico
John D'Errico le 10 Mai 2024
Modifié(e) : John D'Errico le 10 Mai 2024
Trivial, in some eyes. ;-) This is one of the simpler implicit problems you might write down, since a direct solution exists in the form of the Wright omega function.
syms a y x alpha k1 b beta
ysol(x,a,b,alpha,beta,k1) = solve(a*log(y) - alpha*y + b*log(x) - beta*x - k1,y)
ysol(x, a, b, alpha, beta, k1) = 
And of course, you have not provided any of the constants. But if you did, I could even evaluate it.
ysol(3,4,5,6,7,8)
ans = 
double(ysol(1,2,3,4,5,6))
ans = -2.2686 + 1.3091i
I'd bet for some sets of those parameters, the result will even be real. I don't need to change a lot.
double(ysol(1,-2,3,4,5,6))
ans = 0.0041
  1 commentaire
João Pedro
João Pedro le 11 Mai 2024
Thank you very much, this answer helped a lot. I learned one more thing. What I needed most was a y(x) function. Just one more question, how can the omega variable that appears be determined? Below I leave the values ​​that I am using in the problem.
a = 12;
b = 6;
alpha = 4;
beta = 2.5;
x0 = 2.5;
y0 = 1.5;
k1 = a*log(y0) - alpha*y0 + b*log(x0) - beta*x0;
f1 = @(x,y) a*log(y) - alpha*y + b*log(x) - beta*x - k1;
fp = fimplicit(f1,[0 7 0 6]);

Connectez-vous pour commenter.

Plus de réponses (1)

Steven Lord
Steven Lord le 10 Mai 2024
Let's take a simpler example and call fimplicit with an output argument, the handle of the graphics object that fimplicit plots.
f1 = @(x,y) x.^2-y.^2+sin(x).*cos(y);
h = fimplicit(f1);
Among the properties the object h returned from fimplicit has are XData and YData properties.
X = h.XData;
Y = h.YData;
Let's plot the X and Y data to see if it gives us the same plot.
figure
plot(X, Y)
  1 commentaire
João Pedro
João Pedro le 11 Mai 2024
Thanks for the answer, getting the entire set of points used to build the graph with the fp.XData and fp.YData commands helped a lot too.

Connectez-vous pour commenter.

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by