clear all;
x=[0:100]/100 *8*pi;

s=sin(x);
n=rand(size(s))-0.5;
c=s+n;

%==================================================
figure(1);
clf;

subplot(4,1,1);
plot(x,s);
axis([min(x) max(x) -2 2]);

subplot(4,1,2);
plot(x,n);
axis([min(x) max(x) -2 2]);

subplot(4,1,3);
plot(x,c);
axis([min(x) max(x) -2 2]);

%==============================================
sf=fft(s);
nf=fft(n);
sf2=abs(sf).^2;
nf2=abs(nf).^2;
w=sf2./(sf2+nf2);

cf=fft(c);
cwf=cf.*w;
cw=ifft(cwf);

subplot(4,1,4);
plot(x,cw,'r',x,s,'b:');
axis([min(x) max(x) -2 2]);


