function rms=plotspectrumRMS(freq,varargin); % plot cumulative RMS for many spectrums % returns RMS spe=[varargin{:}]; Nspe=size(spe,1); Nfreq=length(freq); cumulativeRMS=[]; for j=1:Nspe data=spe(j,:); cumulativeRMSsquared=zeros(1,Nfreq); for k=(Nfreq-1):-1:1 cumulativeRMSsquared(k)=cumulativeRMSsquared(k+1)+(data(k+1)^2+data(k)^2)*(freq(k+1)-freq(k))/2; end cumulativeRMS=[cumulativeRMS;sqrt(cumulativeRMSsquared)]; end rms=cumulativeRMS(:,1); loglog(freq,spe,freq,cumulativeRMS,'--'); grid on; xlabel('Frequency [Hz]'); ylabel('RMS [?]');