Hello, I really need some help with Matlab. Here\'s the problem: Write a functio
ID: 3783098 • Letter: H
Question
Hello, I really need some help with Matlab.
Here's the problem:
Write a function m file that will take a function f, a vector x, and a calculation type calcType as inputs. It should return either the minimum value of f(), the maximum value of f(), or the average value of f(), over the interval of values defined by x, depending on the value of calcType. You can choose what calcType must be for each case (you can use numbers, words, abbreviations, etc.). Make sure you document your function well so that help processFunc explains clearly what it does and how to use it.
Use as your function definition:
function [output] = processFunc(f, x, calcType)
Write a script m file, which will call your function with the values for f and x in the table below, and confirm you get the indicated values for the minimum, maximum, and average:
And here's the table:
Please help!
function (f) x Minimum Maximum Average f = @(x)sin(x) linspace(pi/4,pi/2) .7071 1 .8998 f = @(x)x.^3-4*x.^2+2 linspace(-4,6) -126 74 -9.5017 f = @(x) x.^3-4*x.^2+2 linspace(-2,2) -22 1.9984 -3.4411Explanation / Answer
// here the f defines the function, x0 defines the range.
fminbnd is a one-dimensional minimizer that finds a minimum for a problem specified by
minxf(x) such that x1<x<x2.
x, x1, and x2 are finite scalars, and f(x) is a function that returns a scalar.
------------------------------------------------------------------------------------------------------------
//YOU CAN ALSO DEFINE THE FUNCTION IN A FILE AND CALL IT USING fminbnd()
eg:
// Write the following function as a file, and save the file as processfunc.m on your MATLAB path
//them call the function fminbnd
----------------------------------------------------------------------------------------------------------------------------------------------
//find the indices of max, min and mean value for y by plotting the graph
// SIMILARLY CHANGE X AND Y ACCORDINGLY TO OBTAIN THE RESULT
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.