⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 untitled5.m

📁 一个利用matlab来模拟数字信号处理过程的
💻 M
字号:
 clear all
 clc
 t=0.0001:0.0001:0.04;% 产生原始信号
 ut=sin(2*pi*300*t)+2*cos(2*pi*200*t);
 figure(1)
 subplot(221);
 plot(t,ut);grid;
 title('input signal');
 xlabel('t');ylabel(' ut=sin(2*pi*300*t)+2*cos(2*pi*200*t)');

 yt=awgn(ut,10,0); %加入高斯白噪声
 subplot(222);
 plot(t,yt);grid;
 title('mixed signal');
 xlabel('t');ylabel('yt=awgn(u,10,0)');
 

 Y=fft(yt);%信号频谱分析
 k=length(t);
 YY=[Y(round(k/2)+1:k) Y(1:round(k/2))];
 x=-5000:(5000*2)/k:5000-(5000*2)/k; 
 subplot(223);
 plot(x,abs(YY));grid;
 axis([-1000 1000 0 500]) 
 title('frequency magnitude');
 xlabel('f');ylabel('Y=fft(yt)');
 subplot(224);
 plot(x,180*angle(YY)/pi);grid;
 axis([-500 500 -400 400])
 title('frequency angle');
 xlabel('f');ylabel('Y=fft(yt)');
 
 figure(2) %信号采样
 subplot(221);
 plot(t,yt);grid;
 title('original signal');
 xlabel('t');ylabel('yt');
 f=400;fs=800;
 Ts=1/fs;
 T=0:Ts:0.1
 un=sin(2*pi*300*T)+2*cos(2*pi*200*T);
 yn=awgn(un,10,0);
 subplot(222);
 stem(T,yn);grid;
 axis([0 0.04 -4 4]) 
 title('sampled signal');
 xlabel('t');ylabel('yn');

 Yn=fft(yn);
 K=length(T);
 X=0:(400*2)/K:800-(400*2)/K; 
 subplot(223);
 plot(X,abs(Yn));grid;
 title('sampled signal');
 xlabel('t');ylabel('Yn');
 subplot(224);
 plot(X,angle(Yn));grid;
 title('sampled signal');
 xlabel('t');ylabel('Yn');
 
 figure(3)%信号滤波
 Wn=[160 240]/400;
 [b,a]=butter(9,Wn);
 freqz(b,a,128,1000)
 
 
 
 
 
 
 
 
 
 
 
 
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -