clc;
clear;

fs=48000;                       %vzorkovaci frekvence
f=500;                          %pozadovana frekvence
Q=2*pi*f/fs;                    %theta

B(1)=0;                         %B koeficienty
B(2)=sin(Q);
A(1)=1;                         %A koeficienty
A(2)=-2*cos(Q);
A(3)=1;

N=1000;                          %delka posloupnosti
x=zeros(1,N);
x(1)=1;                         %dirac

y=filter(B,A,x);                %generovani vystupni posloupnosti
subplot(2,1,1);
axis([0 1000 -1.2 1.2]);
hold;
plot(y);

%B(1)=ceil(B(1)*32768)/32768;    %kvnatizace koeficientu na 16b.
%B(2)=ceil(B(2)*32768)/32768;
%A(1)=ceil(A(1)*32768)/32768;
%A(2)=ceil(A(2)*32768)/32768;
%A(3)=ceil(A(3)*32768)/32768;

B(1)=ceil(B(1)*256)/256;        %kvnatizace koeficientu na 8b.
B(2)=ceil(B(2)*256)/256;
A(1)=ceil(A(1)*256)/256;
A(2)=ceil(A(2)*256)/256;
A(3)=ceil(A(3)*256)/256;

y2=filter(B,A,x);               %generovani vystupni posloupnosti
subplot(2,1,2);
axis([0 1000 -1.2 1.2]);
hold on;
plot(y2);
hold off;

pause;
pzmap(B,A);
cc=exp(i*(-10000:10000)/3000);
hold
plot(cc,'g');


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Taylor:
%clc;
%clear;
%for x = -1000:1000,
%  y(x+1001)=1-(x/100)^2/2+(x/100)^4/24-(x/100)^6/720+(x/100)^8/40320;
%end
%plot(y(850:1150));
%z=y(850:1150);
%plot(z);
%w=fft(z);
%plot(abs(w));
