function odsumet2

t=linspace(0,500,5000);
x=-3*cos(pi*t)+5*sin(t)+2*sin(exp(1)*t);
xs=x+10*randn(size(x));
close all

velikost=0.5*[1000 600];
h=figure('Position',[00 200 velikost],'visible','on');
set(h,'PaperUnits','points');
set(h,'PaperSize',velikost);
set(h,'PaperPosition',[1 1 velikost]);
axes1 = axes('Parent',h,'Position',[0.1275 0.1375 0.7792 0.775]);
set(h,'defaultAxesFontSize',14)

plot(t,x,t,xs,'linewidth',2);
title('Zasumeny dlouhy signal')
waitforbuttonpress;
plot(t,x,t,xs,'linewidth',2);
title('Puvodni/zasumeny signal')
xlim([0,20])
legend('puvodni','zasumeny');
waitforbuttonpress

Xs=fft(xs);
plot(abs(Xs),'linewidth',2);
title('Ve frekvencni domene')
waitforbuttonpress;
title('Piky signalu jsou v sumu dobre zretelne')
xlim([0 300])
waitforbuttonpress;

b=3;
f=1:length(Xs);
Xs(abs(f-250)>b&abs(f-80)>b&abs(f-217)>b)=0;
plot(abs(Xs),'linewidth',2);
xlim([0 300])
title('Odfiltrujeme sum ...')
waitforbuttonpress;

y=ifft(Xs);
y=2*real(y);
plot(t,x,t,xs,t,y,'linewidth',2);
title('Rekonstrukce signalu')
xlim([0 300]);
legend('puvodni','zasumeny','rekonstruovany')
waitforbuttonpress

y=ifft(Xs);
y=2*real(y);
plot(t,x,t,xs,t,y,'linewidth',2);
title('Rekonstrukce signalu')
xlim([100 130]);
legend('puvodni','zasumeny','rekonstruovany')
