The integration seems correct based on the implied initial conditions.
The acceleration has frequency of 25 Hz, not 50 Hz.
dispnf = cumtrapz(t, velnf);
We see that cumtrapz starts the integration at 0 for both velnf and dispnf
Let's get the exact solutions for velocity and displacement, don't forget the constants of integration
vel = int(2*sin(2*sym(pi)*25*sym('t')),sym('t')) + sym('C1')
vel =
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1658006/image.png)
disp = simplify(int(vel,sym('t'))) + sym('C2')
disp =
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1658011/image.png)
In accordance with the cumtrapz, we have to select C1 and C2 such that vel(0) = disp(0) = 0;
C1 = solve(subs(vel,sym('t'),0))
C1 =
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1658016/image.png)
C2 = solve(subs(disp,[sym('t') sym('C1')],[0 C1]))
Now plot
fplot(subs(vel,sym('C1'),C1),[0 1])
fplot(subs(disp,[sym('C1') sym('C2')],[C1 C2]),[0 1])
which are essentially the same plots as using cumtrapz.