message to binary, symbol and bits
5 views (last 30 days)
Show older comments
I have following part of code. I want to send text message using BPSK and FHSS and receive and retrieve text. I need to calculate symbol rate, bit rate, hop rate, symbols per hop, hop duration, bpsk bandwidth, spreading bandwidth etc However its confusing which parameters are actually show symbol, bit, hop etc what is N here frequency, symbol, bits...what is T, dwell time, symbol duration etc..what is binarMessage, s, and signal.
message = 'mytextmsg'; %input('Enter the message word: ', 's');
% Convert message to binary
binaryMessage = reshape(2bin(message, 8).', 1, 8 * length(message));
% Ensure the binary message has length N (pad with zeros or truncate if necessary)
N = 32;
signal = [];
carrier = [];
T = 180;
t = 0:2*pi/(T-1):2*pi; % Creating 180 samples for one cosine
binaryMessage = binaryMessage(1:N);
% Convert binary message to numeric values (0 and 1)
s = double(binaryMessage) - '0';
% Display the binary message
disp('Binary Message:');
disp(binaryMessage);
% Plot the binary message
subplot(3,1,1);
stem(1:length(s), s); % Use length(s) as the x-axis to match the length of s
set(gca,'XTick',1:N);
title('Binary information');
% Generation of bit pattern/bit stream (Polar NRZ type)
for k = 1:N
if s(1, k) == 0
sig = -ones(1, T); % T no. of MINUS ONES for bit 0
else
sig = ones(1, T); % T no. of ONES for bit 1
end
c = cos(t);
carrier = [carrier c];
signal = [signal sig];
end
bpsk_sig = signal .* carrier; % Modulating the signal
plot(1:N*T, bpsk_sig);
2 Comments
Walter Roberson
on 17 Mar 2024
message = 'mytextmsg'; %input('Enter the message word: ', 's');
% Convert message to binary
binaryMessage = reshape(dec2bin(message, 8).', 1, 8 * length(message));
% Ensure the binary message has length N (pad with zeros or truncate if necessary)
N = 32;
signal = [];
carrier = [];
T = 180;
t = 0:2*pi/(T-1):2*pi; % Creating 180 samples for one cosine
binaryMessage = binaryMessage(1:N);
% Convert binary message to numeric values (0 and 1)
s = double(binaryMessage) - '0';
% Display the binary message
disp('Binary Message:');
disp(binaryMessage);
% Plot the binary message
subplot(3,1,1);
stem(1:length(s), s); % Use length(s) as the x-axis to match the length of s
set(gca,'XTick',1:N);
title('Binary information');
% Generation of bit pattern/bit stream (Polar NRZ type)
for k = 1:N
if s(1, k) == 0
sig = -ones(1, T); % T no. of MINUS ONES for bit 0
else
sig = ones(1, T); % T no. of ONES for bit 1
end
c = cos(t);
carrier = [carrier c];
signal = [signal sig];
end
bpsk_sig = signal .* carrier; % Modulating the signal
plot(1:N*T, bpsk_sig);
Walter Roberson
on 17 Mar 2024
% Ensure the binary message has length N (pad with zeros or truncate if necessary)
N = 32;
%...
binaryMessage = binaryMessage(1:N);
I doubt that is correct. I suspect that you want to create it as a multiple of N rather than being exactly N. More like
modN = mod(length(binaryMessage),N);
if modN ~= 0
binaryMessage = [binaryMessage, repmat('0', N - modN)];
end
Answers (0)
See Also
Categories
Find more on BPSK in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!