matlab – Direct Sequence Spread Spectrum (DSSS) of Binary Phase Shift Keying (BPSK)
I need help coding Direct Sequence Spread Spectrum into my Binary Phase Shift Keying Code. DSSS is the main piece of my objective. The code provided is composed of Binary Information, Carrier Wave, BPSK, AWGN, Impulse Noise.
clc;
clear all;
close all;
N = 7;
I = randi([1], 1, N);
I = [1 0 1 0 1];
for V = 1:length(I) %Binary Phase
if I(V) == 1
nn(V) = 1;
else
nn(V) = -1;
end
end
i = 1;
t = 0:0.0001:length(I);
for j = 1:length(t)
if t(j) <= i
y(j) = nn(i);
else
i = i + 1;
end
end
Fc = sin(2 * pi * 2 * t);
x = y .* Fc;
% AWGN Noise
SNRdB = 10; % Adjust SNR as needed
snr_lin = 10^(SNRdB / 10);
noise_variance = 1 / snr_lin;
noise = randn(size(t)) * sqrt(noise_variance);
AWGN = x + noise;
% Impulse Noise Parameters
impulse_amplitude = 10; % Adjust the amplitude as needed
impulse_prob = 0.01; % Probability of an impulse at each time index
impulse_noise = zeros(size(t));
impulse_indices = rand(size(t)) < impulse_prob;
impulse_noise(impulse_indices) = impulse_amplitude;
IMPULSE = x + impulse_noise;
subplot(5, 1, 1);
plot(t, y);
axis([0, length(I), -2, 2]);
xlabel('Time');
ylabel('Voltage')
title('Transmitted Binary Information');
subplot(5, 1, 2);
plot(t, Fc);
axis([0, length(I), -2, 2]);
xlabel('Time');
ylabel('Voltage');
title('Carrier Signal');
subplot(5, 1, 3);
plot(t, x);
axis([0, length(I), -2, 2]);
xlabel('Time');
ylabel('Voltage');
title('BPSK');
subplot(5, 1, 4);
plot(t, AWGN);
axis([0, length(I), -2, 2]);
xlabel('Time');
ylabel('Voltage');
title('BPSK with AWGN Noise');
subplot(5, 1, 5);
plot(t, IMPULSE);
axis([0, length(I), -2, 2]);
xlabel('Time');
ylabel('Voltage');
title('BPSK with Impulse Noise');
I did try to code DSSS into the BPSK code along with the AWGN and Impulse Noise but results got errors, and no visible outputs in its plots or graphs.
Read more here: Source link
