We are working with BPSK Demodulation. I want to plot the btilda and bhat variables in this code on the same graph so I can compare them. Does anyone know how to do that?
code:
%% This file will simulate BPSK
clcclear all;% generate logical data bits
nb = 25;c = 2*(randn(nb,1) > 0)-1; % generate random 25 bits
% BPSK modulation
Fs = 5e3; % sampling frequency for signal representation
Ts = 1/Fs; % sampling period
T = 1e-2; % symbol period
fc = 1e2; % carrier frequency
phi = 0; % phase offset
% time vector
t = 0:Ts: nb*T - Ts;% Modulate the data bits to BPSK signal
[x,xc,btilda] = BPSK_MOD(c, fc, phi, T, Ts);% plot the data, carrier, and modulated signal
figure;subplot 311; plot(t, btilda); title('Information bits');ylabel('amplitude'); xlabel('time');subplot 312; plot(t, xc); title('Carrier Signal');ylabel('amplitude'); xlabel('time');subplot 313; plot(t, x); title('BPSK modulated Signal');ylabel('amplitude'); xlabel('time');% AWGN channel noise
SNR = 10;sigma = 10^(-SNR/20); % noise standard deviation
noise = sigma*randn(size(x));x = x + noise;% receiver processing.
bhat = BPSK_DMOD(x, fc, phi, Ts); bRcvd = receivedSignalBitEst(bhat, T, Ts);% plot the received signal, noise, and demodulate it
figure;subplot 311; plot(x); title('Received data signal');grid on;subplot 312; plot(noise); title('Noise level ');grid on;subplot 313; plot(bhat);title('Received data signal'); grid on;% calculate number of bits in error
bErr = length(find((c(1:end-1) - bRcvd)~= 0));fprintf('Total bits are in Error: %d\n', bErr);
Best Answer