Clear Filters
Clear Filters

How can I solve this implicit function in MatLab?

6 views (last 30 days)
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.

Accepted Answer

John D'Errico
John D'Errico on 10 May 2024
Edited: John D'Errico on 10 May 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 Comment
João Pedro
João Pedro on 11 May 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]);

Sign in to comment.

More Answers (1)

Steven Lord
Steven Lord on 10 May 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 Comment
João Pedro
João Pedro on 11 May 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.

Sign in to comment.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!