Hi Mang,
To generate a Binary Phase Shift Keying (BPSK) signal for Direct Sequence Spread Spectrum (DSSS) for 5 users, kindly refer to the following code:
data_length = 100; % Length of the data sequence
num_users = 5; % Number of users
% Generate random binary data for each user with the desired data length
user_data = zeros(num_users, data_length);
for i = 1:num_users
user_data(i, :) = randi([0, 1], 1, data_length);
end
% Using Barker code as spreading code
spreading_code = [+1, +1, +1, -1, -1, -1, +1, -1, -1, +1, -1];
% Create the DSSS waveform for each user
dsss_waveforms = zeros(num_users, data_length * length(spreading_code));
for i = 1:num_users
user_dsss = kron(user_data(i, :), spreading_code);
dsss_waveforms(i, :) = user_dsss;
end
% Plot the DSSS waveforms for all the users
time = 1:size(dsss_waveforms, 2);
figure;
hold on;
for i = 1:num_users
plot(time, dsss_waveforms(i, :));
end
title('DSSS Waveforms for 5 Users');
xlabel('Time');
ylabel('Amplitude');
legend('User 1', 'User 2', 'User 3', 'User 4', 'User 5');
grid on;
hold off;
I hope this answer resolves your query.
Regards,
Nithin Kumar.