- Frequencies are set to "br" and "br/2" where br is the bit rate. This modification makes sure that the frequency deviation is "br/2" which is a characteristic of MSK modulation.
- A “phase” variable is introduced and updated after each bit to maintain phase continuity.
- Cosine functions are dynamically updated with frequencies and phase to achieve MSK.
How to generate a MSK signal?
20 ビュー (過去 30 日間)
古いコメントを表示
It turned out to form a FSK signal, but how to ensure phase continuity is not clear? The first picture shows the problem...
0 件のコメント
回答 (1 件)
Yukthi S
2024 年 9 月 4 日
編集済み: Yukthi S
2024 年 9 月 4 日
I assume that you aim to achieve phase continuity to transform the generated FSK signal into an MSK signal.To do so, I made some changes to the code to ensure phase continuity in the generated signal.
The modified code is given below to help you get started:
clc;
clear all;
close all;
% M-sequence generator setup
n = 4; % Degree of the polynomial (can be adjusted)
c = [1 0 0 1 1]; % Feedback polynomial coefficients (example for n=4)
c = c(2:end);
M = 2^n - 1; % Length of the M-sequence
% Initialize the shift register with a non-zero state
shift_register = [1 zeros(1, n-1)];
a = zeros(1, M);
% Generate M-sequence
for j = 1:M
feedback_bit = mod(sum(shift_register .* c), 2);
a(j) = shift_register(end);
shift_register = [feedback_bit, shift_register(1:end-1)];
end
bp = 0.001; % Bit period
disp('Binary information at Transmitter:');
disp(a);
% Representation of transmitting binary information as digital signal
bit = [];
for n = 1:length(a)
if a(n) == 1
se = ones(1, 100);
else
se = zeros(1, 100);
end
bit = [bit se];
end
t1 = bp/100:bp/100:100*length(a)*(bp/100);
% MSK Modulation
A = 1; % Amplitude of carrier signal
br = 1/bp; % Bit rate
f1 = br; % Frequency for binary '1'
f2 = br/2; % Frequency for binary '0'(ensuring frequency deviation iss br/2)
t2 = bp/99:bp/99:bp;
ss = length(t2);
m = [];
phase = 0; % Initial phase to maintain phase continuity
for i = 1:length(a)
if a(i) == 1
freq = f1;
else
freq = f2;
end
y = A * cos(2 * pi * freq * t2 + phase);
m = [m y];
% Update phase for continuity
phase = phase + 2 * pi * freq * bp;
end
t3 = bp/99:bp/99:bp*length(a);
figure;
hold on;
plot(t1, bit, 'LineWidth', 2, 'DisplayName', 'Digital Signal');% Plot digital signal
grid on;
% Plot MSK modulated signal
plot(t3, m, 'DisplayName', 'MSK Modulated Signal');
xlabel('Time (sec)');
ylabel('Amplitude (volt)');
title('Digital Signal and MSK Modulated Signal');
legend show;
axis([0 bp*length(a) -1.5 1.5]);
Hope you will find this helpful!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で FSK についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!