GMSK的调制解调matlab代码
时间: 2023-11-18 16:05:21 浏览: 177
以下是GMSK的调制和解调的MATLAB代码示例:
调制代码:
```matlab
% GMSK Modulation
% Input: Bit stream, BT product
% Output: Modulated signal
function [s, t] = gmsk_modulation(bits, BT)
% Bit stream to symbols
M = 2; % QPSK modulation
symbols = bi2de(reshape(bits, M, [])', 'left-msb');
symbols = pskmod(symbols, M, pi/M);
% GMSK modulation
fs = 100; % Sampling frequency
Ts = 1/fs; % Sampling interval
Tb = 1; % Bit period
Tb_s = round(Tb/Ts); % Number of samples per bit
fc = BT/Tb; % Carrier frequency
kf = 1/(2*pi*fc*Tb); % Modulation index
phi = 0; % Initial phase
s = zeros(1, Tb_s*length(symbols));
for i = 1:length(symbols)
for j = 1:Tb_s
phi = phi + 2*pi*kf*(symbols(i)-1/2)*sin(2*pi*fc*j*Ts+phi);
s((i-1)*Tb_s+j) = sin(phi);
end
end
% Time axis
t = (0:length(s)-1)*Ts;
end
```
解调代码:
```matlab
% GMSK Demodulation
% Input: Modulated signal, BT product
% Output: Bit stream
function bits = gmsk_demodulation(s, BT)
% GMSK demodulation
fs = 100; % Sampling frequency
Ts = 1/fs; % Sampling interval
Tb = 1; % Bit period
Tb_s = round(Tb/Ts); % Number of samples per bit
fc = BT/Tb; % Carrier frequency
kf = 1/(2*pi*fc*Tb); % Modulation index
phi = 0; % Initial phase
bits = zeros(1, length(s)/Tb_s);
for i = 1:length(bits)
sample = s((i-1)*Tb_s+1:i*Tb_s);
phi_diff = diff(unwrap(angle(sample)));
bits(i) = sum(phi_diff > 0)/(2*pi);
end
% Symbols to bit stream
M = 2; % QPSK modulation
symbols = pskdemod(de2bi(bits, M, 'left-msb'), M, pi/M);
bits = reshape(de2bi(symbols, M, 'left-msb')', 1, []);
end
```
需要注意的是,这里使用了QPSK调制,因此输入的比特流应该是2的倍数。另外,BT product可以根据具体的系统要求进行调整。
阅读全文