
% Test on signal constellations
% Shengli Zhou, 09/18/2002


T=1;	 	 % each symbol occupy 1 second
step=0.001;	
t=0:step:1-step; % sampling the continuous time signal
fc=4;		 % the carrier frequency

% PAM
symbols=[1 3 1 3];	% four symbols are transmitted
time=0:step:length(symbols)-step;	
x=[];
for i=1:length(symbols)
    x=[x,symbols(i)*cos(2*pi*fc*t)];
end

figure(1)
plot(time, x);
xlabel('t');
ylabel('x(t)');
axis([0 4 -4 4]);
grid
print -deps -f1 pam_signal.eps


% PSK
x=[];
for i=1:length(symbols)
    theta=symbols(i)*2*pi/4;
    x=[x,cos(2*pi*fc*t+theta)];
end

figure(2)
plot(time, x);
xlabel('t');
ylabel('x(t)');
axis([0 4 -2 2]);
grid
print -deps -f2 psk_signal.eps

% QAM
sym_I=symbols;
sym_Q=[3 -3 1 1];
x=[];
for i=1:length(symbols)
    x=[x,sym_I(i)*cos(2*pi*fc*t)-sym_Q(i)*sin(2*pi*fc*t)];
end

figure(3)
plot(time, x);
xlabel('t');
ylabel('x(t)');
axis([0 4 -6 6]);
grid
print -deps -f3 qam_signal.eps

% FSK
symbols=[1 3 3 1];
delta_f=2/(T);	% not the minimum spacing for visual effects
x=[];
for i=1:length(symbols)
    x=[x,cos(2*pi*fc*t+2*pi*symbols(i)*delta_f*t)];
end

figure(4)
plot(time, x);
xlabel('t');
ylabel('x(t)');
axis([0 4 -2 2]);
grid
print -deps -f4 fsk_signal.eps


