From: Adrian Iain Lam Date: Fri, 26 Oct 2018 13:41:50 +0000 (+0100) Subject: Fixed passband, should now be correct X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=a4b0109e3e2d8034cf3ad776ed6c607b668b54ec;p=4yp.git Fixed passband, should now be correct --- diff --git a/passband.m b/passband.m index 7abd749..5424ea4 100644 --- a/passband.m +++ b/passband.m @@ -34,8 +34,6 @@ function passband(rolloff, M, numSymbs) t = (0 : 1 / fs : numSymbs / Rsym + (1.5 * span * sps - 1) / fs)'; - - EbN0_db = 0:0.2:10; EbN0 = 10 .^ (EbN0_db ./ 10); @@ -58,15 +56,18 @@ function passband(rolloff, M, numSymbs) xBaseband = txFilter([modData; zeros(span, 1)]); + %fc = 2.5e6; % Carrier freq (Hz) %carrier = sqrt(2) * exp(j * 2 * pi * fc * t); %xPassbandIdeal = normalizeEnergy... % (real(xBaseband .* carrier(1:length(xBaseband))), numSymbs, 1); - txLOFreq = [2.49e6, 2.5e6, 2.51e6]; + %txLOFreq = [2.49e6, 2.5e6, 2.51e6]; %%txLOEnergy = [0.05, 0.9, 0.05]; - txLOEnergy = [0 1 0]; + %txLOEnergy = [0 1 0]; + txLOFreq = [1e8]; + txLOEnergy = [1]; carrier = zeros(length(t), 1); for i = 1 : length(txLOFreq) @@ -75,27 +76,20 @@ function passband(rolloff, M, numSymbs) end xPassband = normalizeEnergy... - (real(xBaseband .* carrier(1:length(xBaseband))), numSymbs, 1); - - sum(abs(xPassband) .^ 2) / numSymbs - input('pause') - + (xBaseband .* carrier(1:length(xBaseband)), numSymbs, 1); for i = 1:plotlen snr = EbN0_db(i) + 10 * log10(log2(M)) - 10 * log10(sps); % why sps? noiseEnergy = 10 ^ (-snr / 10); - yPassband = awgn(xPassband, snr, 'measured'); - - rBaseband = rxFilter([yPassband .* carrier(1:length(yPassband)); zeros(span * sps, 1)]); + rBaseband = rxFilter([yPassband .* conj(carrier(1:length(yPassband))); zeros(span * sps, 1)]); %% truncate filter transients rBaseband = rBaseband(span * sps / 2 + 1 : end); %% normalize energy rBaseband = normalizeEnergy(rBaseband, numSymbs, 1 + noiseEnergy); - rSampled = rBaseband(sps*span/2+1:sps:(numSymbs + span/2) * sps); demodData = pskdemod(rSampled, M, 0, 'gray');