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

4 Ansichten (letzte 30 Tage)
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 Kommentare
Walter Roberson
Walter Roberson am 28 Sep. 2018
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 am 1 Okt. 2018
@ Walter, Thank you for your generous help. I am sorry for prior mistake. I fixed my question and expecting your valuable response.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 28 Sep. 2018
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 Kommentare
Image Analyst
Image Analyst am 29 Sep. 2018
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 am 1 Okt. 2018
Bearbeitet: Md Abu Helal am 1 Okt. 2018
@ 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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by