Question: please help me with the MATLAB code and Plots. [DLV] means deliverables Numerical Differentiation All plot deliverables must be created in MATLAB. You should hand
![please help me with the MATLAB code and Plots. [DLV] means](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f31ce274372_67366f31ce1d1bed.jpg)
please help me with the MATLAB code and Plots. [DLV] means deliverables
Numerical Differentiation All plot deliverables must be created in MATLAB. You should hand in a HW2.m (MATLAB code), and a document showing all of your deliverables. In this particular assignment, you are also required to create a number of additional MATLAB function files. 1) (1 point) Create a MATLAB function 'firstDeriv(' which takes the first [DLV] derivative using the two-point formula. The function must have the following characteristics: The input arguments are a function (see page 28 of Matlab tutorial for documentation on passing functions), step width h for the two-point formula, lower bound, and upper bound, in that order (4 total). The output of the function is an array of samples of the calculated derivative of the input function. The array has (upper bound - lower bound)/(0.1) + 1 points (given a 0.1 spacing between points). Use this function to calculate the derivative of the function f(x) = cos(x). Plot the following [DLV]: The input function (cos(x)) The calculated output array The analytical derivative, i.e., -sin(x) All of the above should be plotted from -pi to pi with 0.1 spacing between points. Numerical Differentiation All plot deliverables must be created in MATLAB. You should hand in a HW2.m (MATLAB code), and a document showing all of your deliverables. In this particular assignment, you are also required to create a number of additional MATLAB function files. 1) (1 point) Create a MATLAB function 'firstDeriv(' which takes the first [DLV] derivative using the two-point formula. The function must have the following characteristics: The input arguments are a function (see page 28 of Matlab tutorial for documentation on passing functions), step width h for the two-point formula, lower bound, and upper bound, in that order (4 total). The output of the function is an array of samples of the calculated derivative of the input function. The array has (upper bound - lower bound)/(0.1) + 1 points (given a 0.1 spacing between points). Use this function to calculate the derivative of the function f(x) = cos(x). Plot the following [DLV]: The input function (cos(x)) The calculated output array The analytical derivative, i.e., -sin(x) All of the above should be plotted from -pi to pi with 0.1 spacing between points
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
