I have two implicit functions as f1(x,y1)=0 and f2(x,y2)=0. Is there any possible way to plot y1/y2 vs x?
6 views (last 30 days)
Show older comments
Suppose you have two any form of implicit functions f1(x,y1)=0 and f2(x,y2)=0. You can't write y1, y2 in terms of x explicitely. Then is it possible to plot any function of y1, y2 versus x, in particular y1/y2 vs x?
0 Comments
Accepted Answer
Torsten
on 9 Jun 2022
f1 = @(x,y1) ...; % insert f1
f2 = @(x,y2) ...; % insert f2
f = @(y) [f1(x,y(1)),f2(x,y(2))]
X = 0:0.1:1; % you might change this x-interval
y0 = [1,1]; % you might change this initial guess for y1 and y2
for i = 1:numel(X)
x = X(i);
y = fsolve(f,y0);
z(i) = y(1)/y(2);
y0 = y;
end
plot(x,z)
2 Comments
Torsten
on 9 Jun 2022
f1 = @(x,y1) y1-x^3; % insert f1
f2 = @(x,y2) y2-x^2; % insert f2
f = @(x,y) [f1(x,y(1)),f2(x,y(2))];
X = 0:0.1:1; % you might change this x-interval
y0 = [1,1]; % you might change this initial guess for y1 and y2
for i = 1:numel(X)
x = X(i);
y = fsolve(@(y)f(x,y),y0);
z(i) = y(1)/y(2);
y0 = y;
end
plot(X,z)
More Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!