% this gives a frequency that is exactly one of the FFT freqs clg t1=[0:255]*2*pi/8; a1=1; x=a1*exp(i*t1); sig=2; x=x+sig*randn(size(x))+i*sig*randn(size(x)); subplot(211); plot([0:255],real(x(1:256))); v=axis; axis([0 256 v(3) v(4)]); title('Re(X) Time Series'); %axis; subplot(212); y=fft(x); plot(2*log10(abs(y))); v=axis; axis([0 256 v(3) v(4)]); title(['Periodogram of X with N=256 and sigma_Y = ',num2str(sig*sqrt(2))]); xlabel('Frequency index j'); ylabel('LOG_10(ABS(Y^2))'); nper=256/8; num = abs(y(nper+1)); y=[y(1:nper),y(nper+2:length(y))]; avnoise=mean(abs(y).*abs(y)); truepar = (length(x)*a1*a1)/(2*sig*sig); estpar = (num^2)/avnoise; disp(['truepar: ',num2str(truepar),' estpar: ',num2str(estpar)]); %gtext(['LOG10 average of noise-only squares: ',num2str(avnoise),... %' signal ',num2str(2*log10(abs(y(nper+1))))]); %axis; print -deps pgram4