forked from kfoysalhaque/m3MIMO
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqpsk_modulation2.m
More file actions
22 lines (18 loc) · 907 Bytes
/
qpsk_modulation2.m
File metadata and controls
22 lines (18 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function [tx_symbols, encoded_bits] = qpsk_modulation2(bits)
% QPSK Modulation function with Hamming encoding
% Input: bits - Input bits to be modulated
% Output: tx_symbols - Modulated QPSK symbols
% encoded_bits - Encoded bits with Hamming code
% Ensure the input bits length is a multiple of 4 for Hamming(7,4) encoding
n = length(bits);
if mod(n, 4) ~= 0
error('Input bits length must be a multiple of 4');
end
% Encode input bits with Hamming code
encoded_bits = encode(bits, 7, 4, 'hamming/binary');
% Generate QPSK symbols from encoded bits
symbols_I = 2*encoded_bits(1:2:end) - 1; % Map bits to I-channel: 0 -> -1, 1 -> 1
symbols_Q = 2*encoded_bits(2:2:end) - 1; % Map bits to Q-channel: 0 -> -1, 1 -> 1
% Combine I and Q channel to form complex symbols
tx_symbols = symbols_I + 1j * symbols_Q;
end