标题基于matlab的短波通信信号基本样式(AM、DSB、FM、2ASK、2FSK、2PSK)
最近学校老师布置的通信信号的仿真任务,本来仿真一个普通信号并不是一件难事,但是老师要求按照实际的频段来仿真,因此,我做的是3-30MHz的信号。编程小白一个,发现网上仿真信号的频率都比较小,将其调到高频后会有一些不好操作的地方,所以就在网上找了一阵子,然后将短波频段的仿真信号做出来了,跟大家分享一下。因为在网上找了许久,所以可能会无意识的引用到其他博主的代码,如果代码涉及到这类事情,望大家告知,我立马撤除。
PS:本人编程小白一个,尤其是遇到信号处理这一块内容,头都炸了,我也是第一次写文章,写这篇文章的目的就是想着各位大神看过之后能够指点一二,我跟大家学习学习,先谢过大家了!
AM信号
f_am
= 20e+06; %载波频率为20MHz
f_am_t
= 1e+06; %调制信号频率为1MHz
fs
= 4*f_am
; %采样频率
Tr_am
= 40e-6; %信号脉冲持续时间
t
= 0:1/fs
:2*Tr_am
-1/fs
; %采样时间
N
= length
(t
); %采样点数
df
= fs
/N
; %一个采样点对应的采样频率
n
= -N
/2:1:N
/2-1; %频率的横轴数值
f
= n
*df
*2;
A0_am
= 1.5; %直流偏量幅度
At_am
= sin
(pi
*f_am_t
*t
); %调制信号
y_am
= A0_am
*cos
(pi
*f_am
*t
)+At_am
.*cos
(pi
*f_am
*t
); %调幅信号表达式
fy_am
= abs(fftshift
(fft
(y_am
))); %将信号转化到频域
fy_am_p
= 10*log10
(fy_am
);
subplot
(2,1,1)
plot
(t
/1e3,y_am
);
title
('AM信号时域波形图');
xlabel
('时间(ms)')
ylabel
('幅度')
grid on
subplot
(2,1,2)
plot
(f
/1e6,fy_am_p
)
title
('AM信号频域图')
xlabel
('频率(MHz)')
ylabel
('功率(dB)')
grid on
DSB信号
f_dsb
= 20e+06; %载波频率为20MHz
f_dsb_t
= 0.5e+06; %调制信号频率为
0.5MHz
fs
= 4*f_dsb
; %采样频率
Tr_dsb
= 40e-6; %信号脉冲持续时间
t
= 0:1/fs
:2*Tr_dsb
-1/fs
; %采样时间
N
= length
(t
); %采样点数
df
= fs
/N
; %一个采样点对应的采样频率
n
= -N
/2:1:N
/2-1; %频率的横轴数值
f
= n
*df
*2;
At_dsb
= sin
(pi
*f_dsb_t
*t
); %调制信号
y_dsb
= At_dsb
.*cos
(pi
*f_dsb
*t
); %调幅信号表达式
fy_dsb
= abs(fftshift
(fft
(y_dsb
))); %将信号转化到频域
fy_dsb_p
= 10*log10
(fy_dsb
);
figure
subplot
(2,1,1)
plot
(t
/1e3,y_dsb
);
title
('DSB信号时域波形图');
xlabel
('时间(ms)')
ylabel
('幅度')
grid on
subplot
(2,1,2)
plot
(f
/1e6,fy_dsb_p
)
title
('DSB信号频域图')
xlabel
('频率(MHz)')
ylabel
('功率(dB)')
grid on
FM信号
fc_fm
= 10e+06; %载波频率
fm_fm
= 1e+06; %调制频率
fs_fm
= 4*fc_fm
; %采样率
Tr_fm
= 20e-06; %信号脉冲持续时间
mf
= 20; %调幅指数
t
= 0:1/fs_fm
:2*Tr_fm
-1/fs_fm
;
N
= length
(t
);
df
= fs_fm
/N
;
n
= -N
/2:1:N
/2-1;
f
= n
*df
;
m
= sin
(2*pi
*fm_fm
*t
); %调制信号
y_fm
= cos
(2*pi
*fc_fm
*t
+2*pi
*mf
*1/fs_fm
*cumsum
(m
)); %已调信号
fy_fm_p
= 10*log10
(abs(fftshift
(fft
(y_fm
)))); %已调信号频域
figure
subplot
(2,1,1)
plot
(t
/1e+03,y_fm
)
title
('FM信号时域波形图')
xlabel
('时间(ms)')
ylabel
('幅度')
grid on
subplot
(2,1,2)
plot
(f
/1e+06,fy_fm_p
)
title
('FM信号的频域图')
xlabel
('频率(MHz)')
ylabel
('功率(dB)')
grid on
ASK信号
fc_ask
= 20e+06; %载波频率
fs_ask
= 4*fc_ask
; %采样率
Tr_ask
= 20e-06; %信号脉冲持续时间
t
= 0:1/fs_ask
:Tr_ask
-1/fs_ask
;
s
= round(rand
(1,16)); %0-1调制码
for i
=1:length
(s
)
if s
(i
)==1
xn
((i
-1)*100+1:i
*100) = ones
(1,100);
else
xn
((i
-1)*100+1:i
*100) = zeros
(1,100);
end
end
y_ask_1
= sin
(2*pi
*fc_ask
*t
);
y_ask
= xn
.*y_ask_1
;
figure
plot
(t
*1e+03,y_ask
)
title
('2ASK信号时域波形')
xlabel
('时间(ms)')
ylabel
('幅度')
grid on
2FSK信号
fc_fsk_1
= 10e+06; %频率
1
fc_fsk_2
= 5e+06; %频率
2
fs_fsk
= 4*fc_fsk_1
;
Tr_fsk
= 40e-06;
t
= 0:1/fs_fsk
:Tr_fsk
-1/fs_fsk
;
s
= round(rand
(1,16));
for i
=1:length
(s
)
if s
(i
)==1
xn1
((i
-1)*100+1:i
*100) = ones
(1,100);
xn2
((i
-1)*100+1:i
*100) = zeros
(1,100);
else
xn1
((i
-1)*100+1:i
*100) = zeros
(1,100);
xn2
((i
-1)*100+1:i
*100) = ones
(1,100);
end
end
y_fsk_1
= xn1
.*sin
(2*pi
*fc_fsk_1
*t
);
y_fsk_2
= xn2
.*sin
(2*pi
*fc_fsk_2
*t
);
y_fsk
= y_fsk_1
+y_fsk_2
;
figure
plot
(t
*1e+03,y_fsk
)
title
('2FSK信号时域波形')
xlabel
('时间(ms)')
ylabel
('幅度')
2PSK信号
fc_psk
= 20e+06; %载波频率
fs_psk
= 4*fc_psk
; %采样率
Tr_psk
= 20e-06; %信号脉冲持续时间
t
= 0:1/fs_psk
:Tr_psk
-1/fs_psk
;
s
= round(rand
(1,16)); %0-1调制码
for i
=1:length
(s
)
if s
(i
)==1
xn
((i
-1)*100+1:i
*100) = ones
(1,100);
else
xn
((i
-1)*100+1:i
*100) = -ones
(1,100);
end
end
y_psk_1
= sin
(2*pi
*fc_psk
*t
);
y_psk
= xn
.*y_psk_1
;
figure
plot
(t
*1e+03,y_psk
)
title
('2PSK信号时域波形')
xlabel
('时间(ms)')
ylabel
('幅度')
grid on