BPSK Constellation (Octave) – myCompiler
clc; clear; close all;
N = 10; % Number of bits
data = randi([0 1],1,N);% Random bits
sym = 2*data-1; % BPSK mapping (0->-1, 1->+1)
% BPSK waveform
bit_rate = 1000; Tb = 1/bit_rate;
t = 0:Tb/100:Tb;
Tx = kron(sym,cos(2*pi*bit_rate*t));
% Add noise
SNR = 20;
P = mean(abs(Tx).^2);
noise = sqrt(P/10^(SNR/10))*randn(size(Tx));
Rx = Tx + noise;
% ----- Plots -----
subplot(3,1,1); plot(kron(data,ones(1,length(t))),'LineWidth',1.5);
ylim([-0.5 1.5]); grid on; title('Message Signal');
subplot(3,1,2); plot(Rx); ylim([-2 2]); grid on; title('BPSK Waveform with Noise');
subplot(3,1,3); plot(sym,zeros(1,N),'o'); xlim([-2 2]); ylim([-2 2]);
grid on; xlabel('In-Phase'); ylabel('Quadrature'); title('BPSK Constellation');
Read more here: Source link
