基于MATLAB的模拟调制信号与解调的仿真——DSB

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/hxxjxw/article/details/82666096

     实现模拟调制信号与解调的仿真是我的MATLAB课程设计的一部分,我参考了网上的一些资料,并加入了一些自己的想法,代码已在本地MATLAB编译通过且能正常运行

       DSB——双边带调制

dt=0.001; %时间采样间隔
fm=1; %信源最高频率
fc=10; %载波中心频率
T=5; %信号时长
t=0:dt:T;
mt=sqrt(2)*cos(2*pi*fm*t); %信源
figure(1)
subplot(311);
plot(t,mt);
title('调制信号')
coss=cos(2*pi*fc*t);
subplot(312);
plot(t,coss);
title('载波信号')
%N0=0.01; %白噪声单边功率谱密度
%DSB调制
s_dsb=mt.*cos(2*pi*fc*t);
B=2*fm;
%noise=noise_nb(fc,B,N0,t);
%s_dsb=s_dsb+noise;

subplot(313)
plot(t,s_dsb); %画出DSB信号波形
hold on
plot (t,mt,'r--'); %标出m(t)波形
hold on
plot(t,-mt,'r--');
title('DSB调制信号');


 %DSB相干解调
rt=s_dsb.*cos(2*pi*fc*t);
figure(2);
subplot(311);
plot(t,rt);
title('DSB调制信号与载波信号相乘')
[f,rf]=T2F(t,rt);%傅里叶变换
[t,rt]=lpf(f,rf,fm);%低通滤波
subplot(312)
plot(t,rt);
title('经过低通滤波的相干解调信号波形');
rt=rt-mean(rt);
subplot(313)
[f,sf]=T2F(t,s_dsb);%傅里叶变换
psf=(abs(sf).^2)/T;
plot(f,psf);
axis([-2*fc 2*fc 0 max(psf)]);
title('DSB信号功率谱');

用到的函数

①T2F.m

function [f,sf]= T2F(t,st)
%利用FFT计算信号的频谱并与信号的真实频谱的抽样比较。
%脚本文件T2F.m定义了函数T2F,计算信号的傅立叶变换。
%This is a function using the FFT function to calculate a signal Fourier
%Translation
%Input is the time and the signal vectors,the length of time must greater
%than 2
%Output is the frequency and the signal spectrum
dt = t(2)-t(1);
T=t(end);
df = 1/T;
N = length(st);
f=-N/2*df : df : N/2*df-df;
sf = fft(st);
sf = T/N*fftshift(sf);

②lpf.m

function [t,st]=lpf(f,sf,B)
%This function filter an input data using a lowpass filter
%Inputs: f: frequency samples
% sf: input data spectrum samples
% B: lowpass bandwidth with a rectangle lowpass
%Outputs: t: time samples
% st: output data time samples
df = f(2)-f(1);
T = 1/df;
hf = zeros(1,length(f));%全零矩阵
bf = [-floor( B/df ): floor( B/df )] + floor( length(f)/2 );
hf(bf)=1;
yf=hf.*sf;
[t,st]=F2T(f,yf);
st = real(st);

猜你喜欢

转载自blog.csdn.net/hxxjxw/article/details/82666096