Question: Write a Matlab function that accepts a vector of values and returns a vector of derivatives at those points. Can someone help me understand how
Write a Matlab function that accepts a vector of values and returns a vector of derivatives at those points.
Can someone help me understand how to solve this assignments? Thank you very much!


.
1. Write a Matlab function that accepts a vector of values and returns a vector of derivatives at those points. You can assume that the values are given on an equally spaced array with spacing h. Use the two point central difference formula da 2h for all points except the two endpoints. For the endpoints use a one-sided derivative that uses two points. The function should have the form function [derivative values] - derivative(h,values) The argument h is the spacing between the points and the vector values con tains the function values. The returned vector derivative values should be a vector of the same length as values 2. Demonstrate that your function works by calculating the derivative of sin(2Tx) on the domain x E [0,1]. For the points use a regularly spaced array of node locations with a node at both x-0 and I. This array can be generated easily in Matlab using the linspace command such as points linspace(0, 1, N) where N is the number of points you would like to use. For this assignment, you will do this 4 tim es with N-3.5, 9,so you can see how the approximation changes as the number of points increases (h decreasing by a factor of 2). Once the points are calculated, the function values can be calculated as values - sin(2*pi*points)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
