Hi Gianmarco Broilo
I understand that you are trying to plot the Power Spectral Density (PSD) of the noise from an accelerator and IMU, but the plots are not as expected.
Please modify the code as shown in the code snippet below to get the correct plots.
N = 1e6;
dt = 0.2;
PSD = 10e-12; %PSD of the IMU
sigma2 = PSD/dt; %PSD of WGN is PSD = sigma^2*dt
x = randn(N,1)*sqrt(sigma2);
xi = zeros(size(x));
xint(1) = x(1);
for n = 2:length(x)
xint(n) = (x(n)+x(n-1))/2*dt+xint(n-1);
end
NFFT = 1e5;
[px,~] = pwelch(x,hanning(NFFT),0.5,NFFT,1/dt,'twosided');
[pxint,f] = pwelch(xint,hanning(NFFT),0.5,NFFT,1/dt,'twosided');
Pacc = 10e-14 + (10e-18)*(f.^-2); % modified
Pint = Pacc./(2*pi*f); %modified
loglog(f,Pacc) % modified
hold on
loglog(f,Pint)
hold off
legend('noise IMU','noise Acc')
Hope it helps!