%function [psd,f]=PSDcalc_sam(Fs,timeSerie)
function [psd,f,std_f,f_plot]=PSDcalc_sam(fs,signal)

% PSD calculation   
nfft=length(signal);
noverlap = round(0.9*nfft);
[psd,f] = psdbk(signal,fs,nfft,noverlap);
 
% STD calculation 
f_plot=1:f(end) ; 
rms_total=rmspsd(f,psd,f_plot(1),f_plot(end)) ;

% STD vs BW calculation

for k=1:length(f_plot)
 std_f(k)=rmspsd(f,psd,f_plot(1),f_plot(k))/rms_total
end


  