simulation of xor gate as amixer
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 9 Sep 2015 04:28:38 +0000 (04:28 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Wed, 9 Sep 2015 04:28:38 +0000 (04:28 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2302 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/xormixer.m [new file with mode: 0644]

diff --git a/codec2-dev/octave/xormixer.m b/codec2-dev/octave/xormixer.m
new file mode 100644 (file)
index 0000000..bbecaf1
--- /dev/null
@@ -0,0 +1,37 @@
+% xormixer.m
+% David Rowe Sep 2015
+%
+% Testing xor gate as a mixer for constant amplitude
+% modulation schemes
+
+n = 1024;
+carrier = modulation = zeros(1,n);
+
+Tc = 4; % carrier period
+for i=1:Tc:n
+  carrier(i:i+Tc/2-1) = 1;
+end
+
+Tm = 32; % modulation signal period
+for i=1:Tm:n
+  modulation(i:(i+Tm/2-1)) = 1;
+end
+
+carrier = carrier .* hanning(n)';
+modulation = modulation .* hanning(n)';
+mixer = xor(carrier,modulation) .* hanning(n)';
+
+figure(1);
+clf
+subplot(311)
+plot(abs(fft(carrier)))
+axis([1 n 0 n/2]);
+
+subplot(312)
+plot(abs(fft(modulation)))
+axis([1 n 0 n/2]);
+
+subplot(313)
+plot(abs(fft(mixer)))
+axis([1 n 0 n/2]);
+