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

MAE1090 HW10 4.m Write a function function m-file, funcstat.m, that calculates t

ID: 3721852 • Letter: M

Question

MAE1090 HW10 4.m Write a function function m-file, funcstat.m, that calculates the minimum, maximum, and mean values for a function evaluated over a specified vector of independent variable values Function syntax: [fmin, fmax, fmean] -funcstat (f,x)i The first input to the function, f, is a function handle, and the second input, x, is a vector of values over which to evaluate the function f. The outputs are the minimum, maximum, and mean values of f (x). (Note that these don't represent the true minimum, maximum, and mean of the function itself, but only the minimum, maximum, and mean of the values that result from evaluating the function at the given x values.) Calculate fmin, fmax, and frean without using MATLAB's built-in statistical functions (i.e., min·m, max.m, and mean.m). Write a second m-file, MAE1090_HW10_4.m, in which you define the following as an anonymous function: f(x) cos(5(x - 5)) [cos(0.2(x - 6)) -0.5] Write your anonymous function such that it can operate on vectors of independent variable values. Generate a vector of x values ranging from 0 to 10 in steps of 0.01. Pass the handle to the anonymous function and the x vector to funcstat.m and display the results to the command window.

Explanation / Answer

MAE2090_HW10_4.m :

f = @(x) (cos(5*(x-5))(cos(0.2*(x-6))-0.5));

step=0.01;

x=(0:step:10);

funcstat(f,x);

funcstat.m:

[fmin, fmax, fmean] = functstat(f, x)

values = f(x)

end