DSPRelated.com
Forums

Help! on ASK, FSK, BPSK demodulation

Started by hwcl...@gmail.com March 17, 2008
Hi, I didn't use the default functions in matlab to plot modulations. I use my own code. Do you guys have any suggestion how to generate demodulation plot? Do I have to use "xcorr"? my code are as follow:

h=[1 1 0 1 0 0 1 1 1 0];
bit=[];
for n=1:2:length(h)-1;
if h(n)==0 & h(n+1)==1
se=[zeros(1,50) ones(1,50)];
elseif h(n)==0 & h(n+1)==0
se=[zeros(1,50) zeros(1,50)];
elseif h(n)==1 & h(n+1)==0
se=[ones(1,50) zeros(1,50)];
elseif h(n)==1 & h(n+1)==1
se=[ones(1,50) ones(1,50)];
end
bit=[bit se];
end
plot(bit,'LineWidth',1.5);grid on;
axis([0 500 -1.5 1.5]);

fc0;
g=handles.bits;
n=1;
while n<=length(g)
if g(n)==0
tx=(n-1)*0.1:0.1/100:n*0.1;
p=(1)*sin(2*pi*fc*tx);
plot(tx,p,'LineWidth',1.5);grid on;
hold on;
else
tx=(n-1)*0.1:0.1/100:n*0.1;
p=(2)*sin(2*pi*fc*tx);
plot(tx,p,'LineWidth',1.5);grid on;
hold on;
end
n=n+1;
end