Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a user-defined MATLAB. AU function that calculates the local maximum or mi

ID: 1857080 • Letter: W

Question

Write a user-defined MATLAB. AU function that calculates the local maximum or minimum of a quadratic function of the form f(x) - ax2+bx + c . For the function name and arguments use {x,y} = maxmin (a,b, c) The input arguments are the constants a, b. and c, and the output arguments are the coordinates x and y of the maximum or the minimum Use the function to determine the maximum or minimum of the following functions f(x)=2x2+9x-20 f(x)= -3*2 + 15x+50 Solve the problem using MATLAB program and a function as m-files. Program the input and output in the program and perform the actual calculation in the function. modification write the problem using a MATLAB program and a function as m-files program in input and output in the program and perform the actual calculation in the function As always: Understand the problem. Invent an algorithm. Code the algorithm in MATLAB. Test the program and debug it if necessary.

Explanation / Answer

To find local maxima or minima, take the derivative of the function with respect to x and set that equal to zero. Then, solve for x. So, for a quadratic equation of the form

y = A*x^2 + B*x + C

The derivative of the function has the form,

dy/dx = 2*A*x + B

Therefore, the x-value for the local extrema is

x = -B/(2*A)

Then, the y-value can be obtained by substituting x back into the original quadratic. So, the associated Matlab function to determine the local extrema looks like:

function [x,y]=maxmin(A,B,C)

x = -B/(2*A);
y = A*x^2 + B*x + C;

end

For your problem, the local minimum is at (3,21). You can call the function minmax and plot the original quadratic by executing the following commands:

[x,y] = minmax(3,-18,48)

xx=-10:10;
yy = 3*xx.^2 - 18*xx + 48;
plot(xx,yy)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote