How do I make this command to get the result correctly? Please help me to solve this..
1 view (last 30 days)
Show older comments
Md Abu Helal
on 1 Oct 2018
Commented: Md Abu Helal
on 2 Oct 2018
I have two functions. for example,
f(x) = 3x^2-2y+5 (plot for x>1);
g(x) = 4x^3-3x-7;
For f(x), x is variable and y is a arbitrary fixed number. So, by choosing arbitrary 'y', I can have many graphs for f(x) (for instance: if 'y=2' then I can have one graph for f(x), and for 'y= 2.01' I will have other graph and so on). And For g(x), x is a variable. So, I will get only one graph for g(x) for non-negative x.
My goal is to find an unique intersection point 'x_0' between g(x) and f(x) such that,
g(x_0) = c(constant) + minimum(f(x)).
here I can change y arbitrarily in f(x), to get my correct 'x_0'. So, I might need to do iteration here. But I don't know how to write this command. Please help me. Thank you for your time.
N.B.:I posted this question couple of days before and there was some typos, that is why I asking again with corrections.
Accepted Answer
Dimitris Kalogiros
on 2 Oct 2018
Edited: Dimitris Kalogiros
on 2 Oct 2018
If you have license for symbolic math toolbox, try this :
close all
clearvars
syms x y
f(x)=3*x^2-2*y+5
g(x)=4*x^3-3*x-7
figure;
fplot(g(x), [0 3]); hold on;
for yval=-5:1:5
f1(x)=subs(f(x),y,yval);
fplot(f1(x),[0,3]);
end
grid on; zoom on;
Results, should be something like this:
3 Comments
Dimitris Kalogiros
on 2 Oct 2018
Try this:
close all
clearvars
syms x y;
f(x)=3*x^2-2*y+5
g(x)=4*x^3-3*x-7
figure;
fplot(g(x), [0 3]); hold on;
for yval=-5:1:5
f1(x)=subs(f(x),y,yval);
fplot(f1(x),[0,3]);
assume(x, 'real')
x_0=vpasolve(g(x)==f1(x), x, [0, inf])
end
grid on; zoom on;
More Answers (0)
See Also
Categories
Find more on Function Creation 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!