How do I calculate acceleration when I have instantaneous values of velocity?

5 views (last 30 days)
I have the x, y, and z components of velocity of Uranus 30 days (can also use 1 day apart data) apart since 1800. I want to calculate its acceleration using this velocity data.
I have used the folowing two equations but neither is giving me a result I expect.
5 point differetiation:
h=0.0833; %step size
for i=3:2697 %I have a total of 2699 data points
V1(i,:)=1/(2*h)*(v_u(i-2,:)-8*v_u(i-1,:)+8*v_u(i+1,:)-v_u(i+2,:)); %v_u is the velocity vector of Uranus
end
Derrivative from first principles:
for i=1:2698
X(i)= (V_u(i+1)-V_u(i))./(0.0833); %V_u is the velocity vector of Uranus
end

Accepted Answer

Wan Ji
Wan Ji on 21 Aug 2021
Use pddiff function attached here, this is easy to use.
t = linspace(0,3*pi,19)';
f = sin(t); % assume this is the velocity
[ft_pd, ftt_pd] = pddiff(f, t); % using pddiff method
ft_true = cos(t); % true value
ft_cen = cendiff(f, mean(diff(t)));% using centro diff method
figure(1); clf
plot(t, ft_pd, 'b--');hold on
plot(t, ft_true, 'r-');
plot(t, ft_cen,'k-.');
legend('dfdt-pddiff','dfdt-exact', 'centro-difference')
It is from the picture that pddiff method works fine!

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!