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

Using MATLAB please solve. Problem 1: Numerical differentiation for equally spac

ID: 3704975 • Letter: U

Question

Using MATLAB please solve.

Problem 1: Numerical differentiation for equally spaced data points (Gilat 6.17) a) Write a MATLAB user-defined function that determines the first and second derivatives of a function that is given by a set of discrete points with equal spacing. For the function name use Idy, d2yl-FirstSecondDeriv (x, y). The input arguments x and y are vectors with the coordinates of the points, and the output arguments dy and d2y are vectors with the values of the first and second derivatives, respectively, at each point. For calculating both derivatives, the function should use the finite difference formulas that have a truncation error of O(h?), i.e, second order difference equations. Hint: Refer to the formulas presented in Table 1 and Table 2 attached. b) Use the function FirstsecondDeriv to calculate the derivatives of the function that is given by the following set of points: 0.5 0 0.5 2.5 3.5 4.5 (x) 3.632 -0393506487 -1282 4518 8.611 -1282 -1591 -15.88 9.402 9017

Explanation / Answer

CODING;

===============

function ydd= SecDeriv(x,y )

N=length(x);

%First find first order derivative

for i=1:(N-1)
   
F1(i)=((y(i+1)-y(i)))/(x(i+1)-x(i));

end

% First derivative is stored in F1
% Now repeat for second

for i=1:(N-2)
   
F2(i)=((F1(i+1)-F1(i)))/(x(i+1)-x(i));

end

ydd=F2;


end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote