How do I make this command to get the result correctly? Please help me to solve this..

조회 수: 1 (최근 30일)
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.

채택된 답변

Dimitris Kalogiros
Dimitris Kalogiros 2018년 10월 2일
편집: Dimitris Kalogiros 2018년 10월 2일
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
Dimitris Kalogiros
Dimitris Kalogiros 2018년 10월 2일
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;

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Function Creation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by