Can somebody help me please to write the code to fulfill this condition in MATLAB?

4 次查看(过去 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 fixing 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 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.
  7 个评论
Walter Roberson
Walter Roberson 2018-9-28
Maybe
syms x y
fx = f(x);
solx = solve( diff(fx, x), x );
infimum = subs(fx, x, solx);
soly = solve(c + infimum == g(y), y);
Md Abu Helal
Md Abu Helal 2018-10-1
@ Walter, Thank you for your generous help. I am sorry for prior mistake. I fixed my question and expecting your valuable response.

请先登录,再进行评论。

回答(1 个)

Image Analyst
Image Analyst 2018-9-28
So, is this what you have:
y = linspace (0, 3, 1000);
gy = 4 * y .^ 3 - 3 * y - 7;
plot(y, gy, 'k-', 'LineWidth', 2);
grid on;
hold on;
ca = {'gy'};
% Next family of equations:
x = linspace(1, 3, 1000);
y = linspace(-12, 10, 13);
for k = 1 : length(y)
fx = 3 * x .^ 2 - 2 * y(k) + 5;
plot(x, fx, '-', 'LineWidth', 2);
ca{k + 1} = sprintf('y = %.2f', y(k));
end
legend(ca, 'location', 'northwest');
fontSize = 24;
xlabel('y, and x', 'FontSize', fontSize);
ylabel('g(y) and F(x)', 'FontSize', fontSize);
and you want the coordinates of the intersections of the curves?
  6 个评论
Image Analyst
Image Analyst 2018-9-29
Not sure I understand. I thought you said
g(y) = 4y^3 - 3y -7;
I don't know what infimum is - apparently you say it's the minimum of f(x).
So then is gy just c-min(fx) where c is some predefined contant? But then this g(y) would be just a constant, and not at all the same cubic formula for g(y). In fact it would not be a functionof y at all, just a function of f(x) which is a function of x. Actually I don't see why you're making it confusing by having the independent (horizontal) variable be called x sometimes and y other times. This is not standard.
Md Abu Helal
Md Abu Helal 2018-10-1
编辑:Md Abu Helal 2018-10-1
@ Image Analyst, Thank you very much for your help to lead me in right direction. After your comment, I studied full contexts three times, I found that there are some confusing term, for which I didn't get the point. Now, I am explaining again: say, I have two functions:
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 fixing 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 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 and sorry for misguiding before. I appreciate your kind help.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by