当前位置:首页 > 基于MATLAB调制解调仿真
n=1; f1=100; f2=300;
fs=1000;%采样频率
t=0:1/fs:n; fre=10;
y1=square(2*fre*pi*t)/2+1.1; dt=1/fs; %定义时间步长。 n1=length(t); %样点个数
%y1=cos(2*pi*fre*t); %余弦信号 f_end=1/dt; %频率轴的显示范围
f=(0:n1-1)*f_end/n1-f_end/2; %频率自变量 Xf=dt*fftshift(fft(y1)); %频谱 figure(1);
subplot(211);plot(t,y1);xlabel('t');title('时间波形');%时间波形
subplot(212);plot(f,abs(Xf));xlabel('f');title('方波幅度频谱');%频谱波形
y2=sawtooth(fre*2*pi*t)/2+1.1; Xf1=dt*fftshift(fft(y2)); %频谱 figure(2);
subplot(211);plot(t,y2);xlabel('t');title('时间波形');%时间波形
subplot(212);plot(f,abs(Xf1));xlabel('f');title('三角波幅度频谱');%频谱波形
z1=10*sin(2*pi*f1*t); z2=10*sin(2*pi*f2*t); yy1=y1.*z1; yy2=y2.*z2; yy3=yy1+yy2;
Xf=dt*fftshift(fft(yy1)); %频谱 figure(3);
subplot(211);plot(t,yy1);xlabel('t');title('时间波形');%时间波形
subplot(212);plot(f,abs(Xf));xlabel('f');title('调制信号频谱');%频谱波形
Xf=dt*fftshift(fft(yy2)); %频谱 figure(7);
subplot(211);plot(t,yy2);xlabel('t');title('时间波形');%时间波形
subplot(212);plot(f,abs(Xf));xlabel('f');title('调制信号频谱');%频谱波形
fp1=100;fp2=200;%FIR滤波器100-200hz fs1=50;fs2=250; As=15;
Ws1=(fp1+fs1)/fs; Ws2=(fp2+fs2)/fs; w=(fp1-fs1)/fs;
M=ceil((As-7.95)/(14.36*w)); hamming=Hamming(M+1);
b=fir1(M,[Ws1,Ws2],hamming); %figure(2);
%freqz(b,1,fs,fs); t=0:1/fs:n;
yyy1=filter(b,2,yy3); zz1=filter(b,2,z1);
fp1=330;fp2=430;%FIR滤波器330-430hz fs1=200;fs2=490; As=15;
Ws1=(fp1+fs1)/fs; Ws2=(fp2+fs2)/fs; w=(fp1-fs1)/fs;
M=ceil((As-7.95)/(14.36*w)); hamming=Hamming(M+1);
b=fir1(M,[Ws1,Ws2],hamming); %figure(4);
%freqz(b,1,fs,fs); t=0:1/fs:n;
yyy2=filter(b,2,yy3); zz2=filter(b,2,z2); k1=yyy1.*zz1; k2=yyy2.*zz2;
N=8;%8阶巴特沃斯低通滤波器上限频率100hz Wn=100/(fs/2);
[b,a] = butter(N,Wn,'low'); kk1=filter(b,a,k1); figure(10);
[H,W]=freqz(b,a); %返回频率响应
subplot(1,2,1);plot(W*fs/(2*pi),abs(H)); xlabel('频率HZ'); ylabel('幅值');grid on;
subplot(1,2,2);plot(W*fs/(2*pi),20*log10(abs(H))); xlabel('频率HZ');ylabel('幅值dB');grid on; figure(4); subplot(211); plot(t,kk1); grid on;
title('解调信号kk1'); kk2=filter(b,a,k2); subplot(212); plot(t,kk2); grid on;
title('解调信号kk2');
Xf2=dt*fftshift(fft(kk1)); %频谱 figure(5);
subplot(211);plot(t,kk1);xlabel('t');title('时间波形');%时间波形
subplot(212);plot(f,abs(Xf2));xlabel('f');title('解调方波幅度频谱');%频谱波形
Xf3=dt*fftshift(fft(kk2)); %频谱 figure(6);
subplot(211);plot(t,kk2);xlabel('t');title('时间波形');%时间波形
subplot(212);plot(f,abs(Xf3));xlabel('f');title('解调三角波幅度频谱');%频谱波形
共分享92篇相关文档