vel =

The integration seems correct based on the implied initial conditions.

Fs = 1000; % sampling freq.

Ts = 1 / Fs; % sampling period or time step

td = 1; % signal duration in seconds

L = Fs * td; % signal length = number of total sampes taken

t = Ts * (0:L-1); % time vector

The acceleration has frequency of 25 Hz, not 50 Hz.

x = 2.* sin(2*pi*25*t); % cosine function with freq. of: 50 Hz

velnf = cumtrapz(t, x);

figure

plot(t,velnf)

dispnf = cumtrapz(t, velnf);

figure

plot(t,dispnf)

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')

disp = simplify(int(vel,sym('t'))) + sym('C2')

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))

C2 = solve(subs(disp,[sym('t') sym('C1')],[0 C1]))

Now plot

figure

fplot(subs(vel,sym('C1'),C1),[0 1])

figure

fplot(subs(disp,[sym('C1') sym('C2')],[C1 C2]),[0 1])

which are essentially the same plots as using cumtrapz.