MATLAB IS REQUIRED FOR THE LAST PART OF THE QUESTION AND TAKE A SCREEN SHOT OF T
ID: 3109248 • Letter: M
Question
MATLAB IS REQUIRED FOR THE LAST PART OF THE QUESTION AND TAKE A SCREEN SHOT OF THE CODE
The following data were collected for distance traveled versus time for a rocket. Calculate the rocket's velocity and acceleration at each time using finite difference formula with error term oCh2); use the formulae for the finite difference approximations as given below. Note that you must have to use a forward difference approximation for the first data point, a backward difference formula for the last data point, and a centered difference scheme for the rest. f i-+2 4 f (xi 1 3 f (xi) i+ Forward Finite-difference f (xi) 2 Ax 3 f (xi) 4 f i-1 f(xi i-2 Backward Finite-difference f (xi) 2 Ax f (xi+1) f i-1 Centered Finite-difference f (xi) OCh2) 2 Ax 5 0 100 125 50 25 75 150 100 105 y, m 32 58 92 78 Plot velocity and acceleration versus time graphsExplanation / Answer
function [fp]=dfdxeven2(x,f)
% x=[0 25 50 75 100 125 150];
% f=[0 32 58 78 92 100 105];
n=length(x);
for i=1:n-1
dx=x(i+1)-x(i);
end
for i=1:n-2
f_forward(i)=(-f(i+2)+4*f(i+1)-3*f(i))/dx;
end
f_forward
for i=3:n
f_backward1(i)=(f(i-2)-4*f(i-1)+3*f(i))/dx;
end
for i=1:n-2;
f_backword(i)=f_backward1(i+2); %shifting
end
f_backword
for i=2:n-1
f_central1(i)=(f(i+1)-f(i-1))/(2*dx);
end
for i=1:n-2
f_central(i)= f_central1(i+1); %shifting
end
f_central
end
% save mfile with same name ''dfdxeven2'' then it will work
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.