message to binary, symbol and bits

조회 수: 4 (최근 30일)
Farhan
Farhan 2024년 3월 17일
댓글: Walter Roberson 2024년 3월 17일
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));
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.
% 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
Walter Roberson
Walter Roberson 2024년 3월 17일
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:');
Binary Message:
disp(binaryMessage);
01101101011110010111010001100101
% 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
Walter Roberson 2024년 3월 17일
% 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

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 BPSK에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by