?? mat_filt_plot.m
字號:
%-----------------------算法的matlab仿真----------------------%
% f1=150; %
% f2=330; %
% fs=1000; %
% fir_coef=0.5; %
% i=3.1415926; %
% dets=1/fs; %
% fp=fir_coef*fs/2; %
%--------------------------------------------------------------------%
disp('%--------濾波算法的 Matlab 仿真結果-------%');
indata_plot;
fid=fopen('filter.vec','r');
[data_in]=fscanf(fid,'%d',[1,inf]);
fclose(fid);
fir_coef=0.5;
fs=1000;
dets=1/fs;
%-----------------------低通濾波----------------------%
b=fir1(15,fir_coef);
b32767=b*32767*0.5;
for j=16:161
y(j-15)=0;
for k=1:16
y(j-15)=y(j-15)+b32767(k)*data_in(j-k+1);
end;
end;
%-------------繪制濾波后的時域和頻域圖---------%
t=0:145;
t=t*dets;
subplot(2,2,3);
plot(t,y*2/32767/1024,'-r');
axis([0,0.1,-2,2])
title ('濾波后的時域圖','fontsize',8);
xlabel ('時間t(秒)','fontsize',8);
ylabel ('幅度y','fontsize',8);
subplot(2,2,4);
stem(abs(fft(y*2/32767/1024)),'*r');
axis([0,80,0,80])
title ('濾波后的頻域圖','fontsize',8);
xlabel ('頻率(赫茲)','fontsize',8);
ylabel ('幅度Y','fontsize',8);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -