diff --git a/phasenmodulation.m b/phasenmodulation.m index c821985..83e3463 100644 --- a/phasenmodulation.m +++ b/phasenmodulation.m @@ -24,24 +24,30 @@ datalen = 10; -d = rand(1,datalen) > 0.5; +pilot = [ 1 0 1 0 ]; -#d = [ 1 0 1 0 1 1 1 0 1 0 0 0 1 0 0 1 0 1 0 1 1 0 1 1 0 0 0 1]; -n = 0:datalen-1; +dr = rand(1,datalen) > 0.5; + +signallen = datalen + size(pilot,2); + +d = [ pilot dr ]; +n = 0:signallen-1; phases = [ -pi/2 pi/2 ]; -Tb = 0.5; -fc = 5; -fa = 200; +Tb = 0.3; +fc = 40; +fa = 1000; subplot(6,1,1) stem(n,d) +timelen = (signallen*Tb - 1/fa); -t = 0:(1/fa):(size(d,2)*Tb - 1/fa); +t = 0:(1/fa):timelen; phi = phases( d( floor(t/Tb) + 1) + 1); subplot(6,1,2) plot(t,phi) +axis([0 timelen -pi pi]) s = cos(2*pi*fc*t + phi); @@ -50,30 +56,34 @@ s = cos(2*pi*fc*t + phi); slow = filter(bs,as,s); subplot(6,1,3); -vgl = cos(2*pi*fc*t); -plot(t,slow,t,vgl); +plot(t,slow); +axis([0 timelen -1.5 1.5]) -noise = 0.5 * randn(size(slow)); +noise = 1 * randn(size(slow)); sn = slow + noise; subplot(6,1,4); + +[bbp,abp] = butter(5,[2*0.5*fc/fa , 2*1.5*fc/fa]); +sbp = filter(bbp,abp,sn); + plot(t,sn); +axis([0 timelen -3 3]) -sr = sn .* cos(2*pi*fc*t); -si = sn .* sin(2*pi*fc*t); -[b,a] = butter(5,2*fc/fa); +sr = sbp .* cos(2*pi*fc*t); +si = sbp .* sin(2*pi*fc*t); + +[b,a] = butter(5,2*0.7*fc/fa); srlow = filter(b,a,sr); silow = filter(b,a,si); - cmplxs = srlow + j*silow; phase = angle(cmplxs); - m = zeros(size(phase)); for i = 1:size(t,2) @@ -83,9 +93,10 @@ endfor subplot(6,1,5); plot(t,phase,t,phases(m+1)); +axis([0 timelen -pi pi]) -ds = zeros(1,datalen); -for i = 1:datalen; +ds = zeros(1,signallen); +for i = 1:signallen; ts = (i-1) * Tb; te = i * Tb; q = t > ts & t < te;