|||
源代码:
clc;
clear;
close all;
data=sin(2*[0:0.02:4]);
for i=1:length(data)
data(i)=data(i)+0.2*randn(1,1);
end
%-------------------------底下是函数接口:data是一维数据!
Y=fft(data);
YY=abs(Y);
figure;plot(YY);title('看图选择底下的滤波范围');
for i=20:180 %20和80根据你的图来调整,选取!
Y(i)=0;
end
data_new=real(ifft(Y));
figure;subplot(1,2,1);plot(data,'r');title('原始信号');grid on;
subplot(1,2,2);plot(data_new,'b');title('滤波后信号');grid on;
%----------------------------------------------------------------------
图表:
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-4-24 10:43
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社