Question: MATLAB. if it is easier to write, the input myFunction can be replaced with the with an euqation like y = sin(x), so that you


MATLAB.
if it is easier to write, the input myFunction can be replaced with the with an euqation like y = sin(x), so that you do not need to call another function.
Please do not use any tools not included in the basic student MATLAB package.
Write a function [ay, X] = myNumDiff (myFunction, a, b, n, option) that computes the derivative of the function myFunction numerically for n evenly spaced points starting at a and ending at b according to the method defined by the variable option. The inputs are myFunction(1 x 1 function handle) specifying the function for which a derivative should be computed, a (1 x 1 double array) specifying the start value over which to find the derivative, b (1 x 1 double array) specifying the end value over which to find the derivative, n (1 x1 double array) the number of evenly spaced points between the start and end values, and option (1 x m character array) specifying the type of differentiation to do. The input argument option is one of the following strings: forward, 'backward, central. The function myNumDiff should do forward differentiation if option is forward, backward differentiation if option is backward, and central differentiation if option is central. The output argument, ay, is the evaluation of the derivative based on the specified method and should be a 1 x (n - 1) double array for the forward and backward method, and dy should be a 1 x (n - 2) double array for the central difference method. The function output X is a double array containing the x-values for which dy was evaluated and should be the same size as dy. If the input argument option is not one of the recognized strings, the outputs dy and X should be assigned nan and a warning should be displayed saying Unrecognized numerical integration method :
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
