【信号去噪】基于FFT和FIR实现信号去噪附matlab代码​

这篇博客介绍了如何使用FFT(快速傅立叶变换)和FIR(无限 impulse response)滤波器在MATLAB中进行信号去噪。通过提供详细的代码片段,作者展示了从信号录制、频谱分析到噪声抑制的完整过程,包括实时音频处理和模拟仿真结果。适合信号处理初学者和Matlab用户学习信号去噪技术。
摘要由CSDN通过智能技术生成

 1 简介

【信号去噪】基于FFT和FIR实现信号去噪附matlab代码​

2 部分代码

% Proyek Sinyal dan Sistem - 02% FFT, FIR, and Denoise%   Universitas : Universitas Indonesiafunction varargout = FFT_IvanWidjanarko_1806148706_Sinsis02(varargin)gui_Singleton = 1;gui_State = struct('gui_Name',       mfilename, ...    'gui_Singleton',  gui_Singleton, ...    'gui_OpeningFcn', @FFT_IvanWidjanarko_1806148706_Sinsis02_OpeningFcn, ...    'gui_OutputFcn',  @FFT_IvanWidjanarko_1806148706_Sinsis02_OutputFcn, ...    'gui_LayoutFcn',  [] , ...    'gui_Callback',   []);if nargin && ischar(varargin{1})    gui_State.gui_Callback = str2func(varargin{1});endif nargout    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});else    gui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT% --- Executes just before FFT_IvanWidjanarko_1806148706_Sinsis02 is made visible.function FFT_IvanWidjanarko_1806148706_Sinsis02_OpeningFcn(hObject, eventdata, handles, varargin)%disable buttonset(handles.ReplayButton,'enable','off');set(handles.FIRFilterButton,'enable','off');set(handles.PlayFIRFilterButton,'enable','off');set(handles.FFTFilterButton,'enable','off');set(handles.PlayFFTFilterButton,'enable','off');set(handles.DenoiseButton,'enable','off');set(handles.PlayDenoiseButton,'enable','off');handles.output = hObject;handles.state = 0;handles.Fs = 8192;handles.lowBound = 300handles.highBound = 3800global nBits;nBits = 16;global recObj;recObj = audiorecorder(handles.Fs,nBits,1);set(recObj,'TimerPeriod',0.05,'TimerFcn',{@audioTimerCallback,handles});xlabel(handles.OriginalTimeDomain,'Time');ylabel(handles.OriginalTimeDomain, 'Amplitude');xlabel(handles.FFTFrequency,'Frequency (Hz)');ylabel(handles.FFTFrequency,'|Y(f)|')xlabel(handles.FIRFrequency,'Frequency (Hz)');ylabel(handles.FIRFrequency,'|Y(f)|')xlabel(handles.DenoiseTimeDomain,'Time');ylabel(handles.DenoiseTimeDomain, 'Amplitude');% Update handles structureguidata(hObject, handles);% --- Outputs from this function are returned to the command line.function varargout = FFT_IvanWidjanarko_1806148706_Sinsis02_OutputFcn(hObject, eventdata, handles)varargout{1} = handles.output;function audioTimerCallback(hObject,event,handles)if(isempty(hObject))    return;endsignal = getaudiodata(hObject);plot(handles.OriginalTimeDomain, signal);% --- Executes on button press in RecordButton.function RecordButton_Callback(hObject, eventdata, handles)%prepare parameterglobal recObj;if handles.state == 0    disp('Start Recording')    set(hObject,'String','Pause');    record(recObj);    handles.state =1 ;        %disable button    set(handles.ReplayButton,'enable','off');    set(handles.FIRFilterButton,'enable','off');    set(handles.PlayFIRFilterButton,'enable','off');    set(handles.FFTFilterButton,'enable','off');    set(handles.PlayFFTFilterButton,'enable','off');    set(handles.DenoiseButton,'enable','off');    set(handles.PlayDenoiseButton,'enable','off');else    disp('Stop Recording')    set(hObject,'String','Record');    stop(recObj);    handles.state = 0;        %enable button    set(handles.ReplayButton,'enable','on');    set(handles.FIRFilterButton,'enable','on');    set(handles.PlayFIRFilterButton,'enable','on');    set(handles.FFTFilterButton,'enable','on');    set(handles.PlayFFTFilterButton,'enable','on');    set(handles.DenoiseButton,'enable','on');    set(handles.PlayDenoiseButton,'enable','on');        xlabel(handles.OriginalTimeDomain,'Time');    ylabel(handles.OriginalTimeDomain, 'Amplitude');    xlabel(handles.FFTFrequency,'Frequency (Hz)');    ylabel(handles.FFTFrequency,'|Y(f)|')endguidata(hObject,handles)% --- Executes on button press in btn_stoprecord.function btn_stoprecord_Callback(hObject, eventdata, handles)disp('Stop Recording')global recordFlag;recordFlag = 0;% --- Executes on button press in ReplayButton.function ReplayButton_Callback(hObject, eventdata, handles)global recObj;global nBits;sig = getaudiodata(recObj);[n m] = size(sig)load gong.mat;soundsc(sig, handles.Fs, nBits);% --- Executes on button press in FFTFilterButton.function FFTFilterButton_Callback(hObject, eventdata, handles)global recObj;sig = getaudiodata(recObj);nfft = 2^nextpow2(length(sig));filterSound = conv(sig,h,'valid');plot(handles.DenoiseTimeDomain, sig);xlabel(handles.DenoiseTimeDomain,'Time');ylabel(handles.DenoiseTimeDomain,'Amplitude')% --- Executes on button press in PlayDenoiseButton.function PlayDenoiseButton_Callback(hObject, eventdata, handles)global filterSoundglobal nBitsload gong.mat;soundsc(filterSound, handles.Fs, nBits);% --- Executes on button press in ExitButton.function ExitButton_Callback(hObject, eventdata, handles)cl = questdlg('Do you want to EXIT?','EXIT',...    'Yes','No','No');switch cl    case 'Yes'        close();        clear all;        return;    case 'No'        quit cancel;end% --- Executes during object creation, after setting all properties.function OriginalTimeDomain_CreateFcn(hObject, eventdata, handles)% hObject    handle to OriginalTimeDomain (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: place code in OpeningFcn to populate OriginalTimeDomain% --- If Enable == 'on', executes on mouse press in5 pixel border.% --- Otherwise, executes on mouse press in 5 pixel border or over ExitButton.function ExitButton_ButtonDownFcn(hObject, eventdata, handles)% hObject    handle to ExitButton (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --- Executes on mouse press over axes background.function OriginalTimeDomain_ButtonDownFcn(hObject, eventdata, handles)% hObject    handle to OriginalTimeDomain (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% --- Executes when Project is resized.function Project_SizeChangedFcn(hObject, eventdata, handles)% hObject    handle to Project (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)

3 仿真结果

4 参考文献

[1]吕晶晶, 赵晶亮, 刘国鹏. 基于MATLAB的振动信号去噪研究[J]. 电子测试, 2011(7):4.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。

代码

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

matlab科研助手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值