📄 main.m
字号:
% %**************************************************************************
% The Base band FM Modulate Algorithm
%--------------------------------------------------------------------------
%% ALGORITHM
% The base band modulation do not need carrier frequency and send the
% signal directly.The signal was separated into I and Q
% So the transmit signal S(t) is defined as follows.
%
% signal_I = cos(Kf / (2 * pi * fm) .* int_v);
% signal_Q = sin(Kf / (2 * pi * fm) .* int_v);
%
% v(t) = cos(2*pi*fm*t) is the signal for modulating
% int_v is the integral of v(t)
%--------------------------------------------------------------------------
%% QUESTION I MEET
%--------------------------------------------------------------------------
clear all
%% parameter
fs = 16000; % the sampling rate.
ts = 1 / fs;
fm = 400; % the frequency of input signal v(t)
T = 0.02; % the duration of signal v(t)
Kf = 21000; % Defining the frequency modulation constant.
fai_v = 130 / 180 * pi; % the initial phase of signal v(t)
fai_mod = 41 / 180 * pi; % the phase delay at modulating moment
fai_de = 21 / 180 * pi; % the phase delay vs signal_send at receiver
%--------------------------------------------------------------------------
% 引入基带信号v(t) = cos(2*pi*fm*t)
t = 0: 1 / fs : T;
v = v_cos(fs,fm,T,fai_v);
%--------------------------------------------------------------------------
%对音频信号进行基带调制,得到I,Q两路信号
[signal_I,signal_Q,int_v] = fm_modulate(fm,fs,Kf,v,fai_mod);
%--------------------------------------------------------------------------
%% 接收端收到I,Q两路基带信号为demod_I,demod_Q,
% 其与输出端I,Q两路的信号signal_I,signal_Q相位偏移fai_de
[demod_I,demod_Q] = fm_signal_received(signal_I,signal_Q,fai_de);
%--------------------------------------------------------------------------
%%对接收到的信号进行FM基带解调
% 求解调信号的瞬时相位
fai = atan2(demod_Q , demod_I);
% 对瞬时相位进行微分得到瞬时频率
m =1 / Kf .* unwrap(diff(fai)) .* fs;
%--------------------------------------------------------------------------
% figure(1)
%
subplot(4,1,1);
plot(signal_I);
subplot(4,1,2);
plot(signal_Q);
subplot(4,1,3);
plot(demod_I);
subplot(4,1,4);
plot(demod_Q);
%
% figure(2)
subplot(2,1,1);
plot(v);
subplot(2,1,2);
plot(m);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -