clear;NS=10;T=0.9;
N=NS*randn(1,1000);
t=linspace(0,1,1000);
X=1+4*sin(2*pi*5*t);
X=X+10*cos(2*pi*10*t+0.6435);
Y=X+N;%Noisy periodic signal.
FY=fft(Y)/1000;FZ=FY;
FZ(find(abs(FY)<T))=0;%threshold.
Z=1000*real(ifft(FZ)); 
SNR=10*log10(sum(X.*X)/sum(N.*N))
subplot(211),plot(t,Y)
subplot(212),plot(t,Z),figure,
subplot(211),stem(0:19,abs(FY(1:20)))
subplot(212),stem(0:19,abs(FZ(1:20)))
