clear all
close all
%%%%%%
% Poissons summationsformel
%%%%%%

figure(1),text(0.2,0.5,'Poissons summationsformel','FontSize',16)
set(gca,'YTickLabel',[],'YTick',[],'XTickLabel',[],'XTick',[])
pause

fs = 4;
a = 0.5;
fmax = (2*fs+1);
X = [0 0 1 0 0]*a;
f = [-fmax -1 0 1 fmax];

subplot(311)
plot(f,X,'b-','LineWidth',2)
title('X(f)','FontSize',16)
%xlabel('f [Hz]','FontSize',16)
axis([-fmax fmax 0 2*a])
set(gca,'FontSize',16)

pause

Y = X;
fy = f;

subplot(312)
plot(fy,Y,'r--','LineWidth',2)
text(0,a+0.2,'m=0','FontSize',16)
title(['X(f-mf_s) : f_s = ',num2str(fs),' Hz'],'FontSize',16)
xlabel('f [Hz]','FontSize',16)
axis([-fmax fmax 0 a+1])
set(gca,'FontSize',16)

pause

Y = [0 0 1 0 0 1 0 0]*a;
fy = [-fmax -1 0 1 fs-1 fs fs+1 fmax];

subplot(312)
plot(fy,Y,'r--','LineWidth',2)
text(0,a+0.2,'m=0','FontSize',16)
text(fs,a+0.2,'m=1','FontSize',16)
title(['X(f-mf_s) : f_s = ',num2str(fs),' Hz'],'FontSize',16)
xlabel('f [Hz]','FontSize',16)
axis([-fmax fmax 0 a+1])
set(gca,'FontSize',16)

pause

Y = [0 0 1 0 0 1 0 0 1 0 0]*a;
fy = [-fmax -fs-1 -fs -fs+1 -1 0 1 fs-1 fs fs+1 fmax];

subplot(312)
plot(fy,Y,'r--','LineWidth',2)
text(0,a+0.2,'m=0','FontSize',16)
text(fs,a+0.2,'m=1','FontSize',16)
text(-fs,a+0.2,'m=-1','FontSize',16)
title(['X(f-mf_s) : f_s = ',num2str(fs),' Hz'],'FontSize',16)
xlabel('f [Hz]','FontSize',16)
axis([-fmax fmax 0 a+1])
set(gca,'FontSize',16)

pause

Y = [0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0]*a;
fy = [-fmax -2*fs-1 -2*fs -2*fs+1 -fs-1 -fs -fs+1 -1 0 1 fs-1 fs fs+1 2*fs-1 2*fs 2*fs+1 fmax];

subplot(312)
plot(fy,Y,'r--','LineWidth',2)
text(0,a+0.2,'m=0','FontSize',16)
text(fs,a+0.2,'m=1','FontSize',16)
text(-fs,a+0.2,'m=-1','FontSize',16)
text(2*fs,a+0.2,'m=2','FontSize',16)
text(-2*fs,a+0.2,'m=-2','FontSize',16)
title(['X(f-mf_s) : f_s = ',num2str(fs),' Hz'],'FontSize',16)
%xlabel('f [Hz]','FontSize',16)
axis([-fmax fmax 0 a+1])
set(gca,'FontSize',16)

pause

Y = [0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0]*a;
fy = [-fmax -2*fs-1 -2*fs -2*fs+1 -fs-1 -fs -fs+1 -1 0 1 fs-1 fs fs+1 2*fs-1 2*fs 2*fs+1 fmax];

subplot(313)
fill(fs/2*[-1 -1 1 1],[0 fs*a+1 fs*a+1 0],0.9*[1 1 1])
hold on
plot(fy,Y*fs,'b-','LineWidth',2)
title(['Y_d(fT) : f_s = ',num2str(fs),' Hz'],'FontSize',16)
xlabel('f [Hz]','FontSize',16)
axis([-fmax fmax 0 fs*a+1])
set(gca,'FontSize',16)

hold off

pause

Y = [0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0]*a;
fy = [-fmax -2*fs-1 -2*fs -2*fs+1 -fs-1 -fs -fs+1 -1 0 1 fs-1 fs fs+1 2*fs-1 2*fs 2*fs+1 fmax]/fs;

subplot(313)
fill(1/2*[-1 -1 1 1],[0 fs*a+1 fs*a+1 0],0.9*[1 1 1])
hold on
plot(fy,Y*fs,'b-','LineWidth',2)
title(['Y_d(\nu) : f_s = ',num2str(fs),' Hz'],'FontSize',16)
xlabel('\nu','FontSize',16)
axis([-fmax/fs fmax/fs 0 fs*a+1])
set(gca,'FontSize',16)

hold off

pause

Y = [0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0]*a;
fy = [-fmax -2*fs-1 -2*fs -2*fs+1 -fs-1 -fs -fs+1 -1 0 1 fs-1 fs fs+1 2*fs-1 2*fs 2*fs+1 fmax];

subplot(313)
fill(fs/2*[-1 -1 1 1],[0 fs*a+1 fs*a+1 0],0.9*[1 1 1])
hold on
plot(fy,Y*fs,'b-','LineWidth',2)
title(['Y_d(fT) : f_s = ',num2str(fs),' Hz'],'FontSize',16)
xlabel('f [Hz]','FontSize',16)
axis([-fmax fmax 0 fs*a+1])
set(gca,'FontSize',16)

pause
plot([-fmax -fs/2 -fs/2 fs/2 fs/2 fmax],[0 0 1 1 0 0]/fs,'r-','LineWidth',2)
hold off

pause

%%%%%%%%
% Pulsamplitudmodulering
%%%%%%%%

figure(2),text(0.2,0.5,'Pulsamplitudmodulering','FontSize',16),pause


f1 = 19/8;
f2 = 21/8;
t = 0:0.01/4:2;
x = 2 + cos(2*pi*f1*(t+1)) + cos(2*pi*f2*(t+1));
T = 0.2;
tT = 0:T:2;
x_T = 2 + cos(2*pi*f1*(tT+1)) + cos(2*pi*f2*(tT+1));
p_T = kron(x_T,[0 1 0]);
%tP = hankel(tT,tT);
%tP = tP(
tP = [-0.2 0 0.2 0 0.2 0.4 0.2 0.4 0.6 0.4 0.6 0.8 0.6 0.8 1 0.8 1 1.2 1 1.2 1.4 1.2 1.4 1.6 1.4 1.6 1.8 1.6 1.8 2 1.8 2 2.2];


%subplot(211)
plot(t,x,'b-','LineWidth',2)
xlabel('t [s]','FontSize',16)
axis([0 2 0 4])
set(gca,'FontSize',16)

pause

plot(t,x,'b-',tT,x_T,'ko','LineWidth',2,'MarkerSize',10)
xlabel('t [s]','FontSize',16)
axis([0 2 0 4])
set(gca,'FontSize',16)

pause

plot(tT/T,x_T,'ko','LineWidth',2,'MarkerSize',10)
xlabel('sampel','FontSize',16)
axis([0 2/T 0 4])
set(gca,'FontSize',16)

pause

plot(tT,x_T,'ko',[0 0.2 0.4],[0 x_T(2) 0],'r--','LineWidth',2,'MarkerSize',10)
xlabel('t [s]','FontSize',16)
axis([0 2 0 4])
set(gca,'FontSize',16)

pause

plot(tT,x_T,'ko',[0.2 0.4 0.6],[0 x_T(3) 0],'r--','LineWidth',2,'MarkerSize',10)
xlabel('t [s]','FontSize',16)
axis([0 2 0 4])
set(gca,'FontSize',16)

pause

plot(tT,x_T,'ko',tP,p_T,'r--','LineWidth',2,'MarkerSize',10)
xlabel('t [s]','FontSize',16)
axis([0 2 0 4])
set(gca,'FontSize',16)

pause

plot(tT,x_T,'ko',tT,x_T,'b-','LineWidth',2,'MarkerSize',10)
xlabel('t [s]','FontSize',16)
axis([0 2 0 4])
set(gca,'FontSize',16)

pause

plot(t,x,'r--',tT,x_T,'b-','LineWidth',2,'MarkerSize',10)
xlabel('t [s]','FontSize',16)
axis([0 2 0 4])
set(gca,'FontSize',16)

