function ejemplotonos(N,P); if(nargin==1) P=1; end M=1024; if(N>M) M=N; end x=zeros(N,P); for i=1:P, x(:,i)=cos(0.35*pi*[0:N-1]'+2*pi*(rand(1,1)-0.5))+cos(0.4*pi*[0:N-1]'+2*pi*(rand(1,1)-0.5))+randn(N,1); end S=abs(fft(x,M)).^2/N; SM=mean(S'); subplot(211); plot(linspace(0,0.5,512),10*log10(S(1:512,:))); ylabel('Densidad Spectral Potencia (dB)') xlabel('frecuencia'); grid on; subplot(212) plot(linspace(0,0.5,512),10*log10(SM(1:512))); grid on; ylabel('Densidad Spectral Potencia (dB)') xlabel('frecuencia');