0
点赞
收藏
分享

微信扫一扫

【信号处理】基于Matlab实现数字均衡器设计

豆丁趣 2022-05-05 阅读 46
算法

1 简介

针对数字信号处理实验课程教学情况,以巩固学生理论知识,提高实际动手能力为目的,利用Matlab软件平台,对"数字信号处理"课程的综合性实验设计进行了探讨和研究.通过综合性实验的设计,使学生深刻地掌握信号处理的方法,培养学生的创新能力和实际动手能力.

2 部分代码

function varargout = balancer(varargin)% BALANCER MATLAB code for balancer.fig%      BALANCER, by itself, creates a new BALANCER or raises the existing%      singleton*.%%      H = BALANCER returns the handle to a new BALANCER or the handle to%      the existing singleton*.%%      BALANCER('CALLBACK',hObject,eventData,handles,...) calls the local%      function named CALLBACK in BALANCER.M with the given input arguments.%%      BALANCER('Property','Value',...) creates a new BALANCER or raises the%      existing singleton*.  Starting from the left, property value pairs are%      applied to the GUI before balancer_OpeningFcn gets called.  An%      unrecognized property name or invalid value makes property application%      stop.  All inputs are passed to balancer_OpeningFcn via varargin.%%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one%      instance to run (singleton)".% % Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name',       mfilename, ...                   'gui_Singleton',  gui_Singleton, ...                   'gui_OpeningFcn', @balancer_OpeningFcn, ...                   'gui_OutputFcn',  @balancer_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 balancer is made visible.function balancer_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject    handle to audio_begin% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% varargin   command line arguments to balancer (see VARARGIN)% Choose default command line output for balancerhandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes balancer wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = balancer_OutputFcn(hObject, eventdata, handles) % varargout  cell array for returning output args (see VARARGOUT);% hObject    handle to audio_begin% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Get default command line output from handles structurevarargout{1} = handles.output;% --- Executes on button press in audioload.function audioload_Callback(hObject, eventdata, handles)% hObject    handle to audioload (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)try    [FileName] = uigetfile('*','Select the audio file');    [handles.audio , handles.audioFs ] = audioread(FileName) ;    Audio_f = abs( fft(handles.audio) );    plot( handles.audio_begin,Audio_f );    handles.audioname.String = FileName;        handles.audio_100 = fx_FIR( handles.audioFs, 1 ,100 , handles.audio);    handles.audio_200 = fx_FIR( handles.audioFs, 100 ,200 , handles.audio);    handles.audio_500 = fx_FIR( handles.audioFs, 200 ,500 , handles.audio);    handles.audio_1K = fx_FIR( handles.audioFs, 500 ,1000 , handles.audio);    handles.audio_2K = fx_FIR( handles.audioFs, 1000 ,2000 , handles.audio);    handles.audio_4K = fx_FIR( handles.audioFs, 2000 ,4000 , handles.audio);    handles.audio_8K = fx_FIR( handles.audioFs, 4000 ,8000 , handles.audio);    handles.audio_16K = fx_FIR( handles.audioFs, 8000 ,20000 , handles.audio);        %now_audio = audio_1K;    handles.now_audio = handles.audio_100 + handles.audio_200 + handles.audio_500 + handles.audio_1K + handles.audio_2K + handles.audio_4K + handles.audio_8K + handles.audio_16K;    sound( handles.now_audio , handles.audioFs );        Audio_ff = abs( fft( handles.now_audio ) );    plot( handles.audio_end , Audio_ff );    end% Update handles structureguidata(hObject, handles);function audioname_Callback(hObject, eventdata, handles)% hObject    handle to audioname (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of audioname as text%        str2double(get(hObject,'String')) returns contents of audioname as a double% --- Executes during object creation, after setting all properties.function audioname_CreateFcn(hObject, eventdata, handles)% hObject    handle to audioname (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.%       See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor','white');end% --- Executes on slider movement.function Freq100_Callback(hObject, eventdata, handles)% hObject    handle to Freq100 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)try    a = get(handles.Freq100 , 'Value');    b = get(handles.Freq200 , 'Value');    c = get(handles.Freq500 , 'Value');    d = get(handles.Freq1K , 'Value');    e = get(handles.Freq2K , 'Value');    f = get(handles.Freq4K , 'Value');    g = get(handles.Freq8K , 'Value');    h = get(handles.Freq16K , 'Value');        handles.Freq100num.String = num2str( a*100 );    all = get(handles.audiovoice , 'Value');    handles.now_audio = all*( a*handles.audio_100 + b*handles.audio_200 + c*handles.audio_500 + d*handles.audio_1K + e*handles.audio_2K + f*handles.audio_4K + g*handles.audio_8K + h*handles.audio_16K );    Audio_ff = abs( fft( handles.now_audio ) );    plot( handles.audio_end , Audio_ff );    endguidata(hObject, handles);% Hints: get(hObject,'Value') returns position of slider%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider% --- Executes during object creation, after setting all properties.function Freq100_CreateFcn(hObject, eventdata, handles)% hObject    handle to Freq100 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor',[.9 .9 .9]);end% --- Executes on slider movement.function slider7_Callback(hObject, eventdata, handles)% hObject    handle to slider7 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% --- Executes during object creation, after setting all properties.function Freq500_CreateFcn(hObject, eventdata, handles)% hObject    handle to Freq500 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor',[.9 .9 .9]);end% --- Executes on slider movement.function Freq1K_Callback(hObject, eventdata, handles)% hObject    handle to Freq1K (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)try    a = get(handles.Freq100 , 'Value');    b = get(handles.Freq200 , 'Value');    c = get(handles.Freq500 , 'Value');    d = get(handles.Freq1K , 'Value');    e = get(handles.Freq2K , 'Value');    f = get(handles.Freq4K , 'Value');    g = get(handles.Freq8K , 'Value');    h = get(handles.Freq16K , 'Value');        handles.Freq1Knum.String = num2str( d*100 );    all = get(handles.audiovoice , 'Value');    handles.now_audio = all*( a*handles.audio_100 + b*handles.audio_200 + c*handles.audio_500 + d*handles.audio_1K + e*handles.audio_2K + f*handles.audio_4K + g*handles.audio_8K + h*handles.audio_16K );    Audio_ff = abs( fft( handles.now_audio ) );    plot( handles.audio_end , Audio_ff );endguidata(hObject, handles);% Hints: get(hObject,'Value') returns position of slider%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider% --- Executes during object creation, after setting all properties.function Freq1K_CreateFcn(hObject, eventdata, handles)% hObject    handle to Freq1K (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor',[.9 .9 .9]);end% --- Executes on slider movement.function Freq2K_Callback(hObject, eventdata, handles)% hObject    handle to Freq2K (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)try    a = get(handles.Freq100 , 'Value');    b = get(handles.Freq200 , 'Value');    c = get(handles.Freq500 , 'Value');    d = get(handles.Freq1K , 'Value');    e = get(handles.Freq2K , 'Value');    f = get(handles.Freq4K , 'Value');    g = get(handles.Freq8K , 'Value');    h = get(handles.Freq16K , 'Value');        handles.Freq2Knum.String = num2str( e*100 );    all = get(handles.audiovoice , 'Value');    handles.now_audio = all*( a*handles.audio_100 + b*handles.audio_200 + c*handles.audio_500 + d*handles.audio_1K + e*handles.audio_2K + f*handles.audio_4K + g*handles.audio_8K + h*handles.audio_16K );    Audio_ff = abs( fft( handles.now_audio ) );    plot( handles.audio_end , Audio_ff );endguidata(hObject, handles);% Hints: get(hObject,'Value') returns position of slider%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider% --- Executes during object creation, after setting all properties.function Freq2K_CreateFcn(hObject, eventdata, handles)% hObject    handle to Freq2K (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor',[.9 .9 .9]);end% --- Executes on slider movement.function Freq4K_Callback(hObject, eventdata, handles)% hObject    handle to Freq4K (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)try    a = get(handles.Freq100 , 'Value');    b = get(handles.Freq200 , 'Value');    c = get(handles.Freq500 , 'Value');    d = get(handles.Freq1K , 'Value');    e = get(handles.Freq2K , 'Value');    f = get(handles.Freq4K , 'Value');    g = get(handles.Freq8K , 'Value');    h = get(handles.Freq16K , 'Value');        handles.Freq4Knum.String = num2str( f*100 );    all = get(handles.audiovoice , 'Value');    handles.now_audio = all*( a*handles.audio_100 + b*handles.audio_200 + c*handles.audio_500 + d*handles.audio_1K + e*handles.audio_2K + f*handles.audio_4K + g*handles.audio_8K + h*handles.audio_16K );    Audio_ff = abs( fft( handles.now_audio ) );    plot( handles.audio_end , Audio_ff );endguidata(hObject, handles);% Hints: get(hObject,'Value') returns position of slider%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider% --- Executes during object creation, after setting all properties.function Freq4K_CreateFcn(hObject, eventdata, handles)% hObject    handle to Freq4K (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor',[.9 .9 .9]);end% --- Executes on slider movement.function Freq8K_Callback(hObject, eventdata, handles)% hObject    handle to Freq8K (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)try    a = get(handles.Freq100 , 'Value');    b = get(handles.Freq200 , 'Value');    c = get(handles.Freq500 , 'Value');    d = get(handles.Freq1K , 'Value');    e = get(handles.Freq2K , 'Value');    f = get(handles.Freq4K , 'Value');    g = get(handles.Freq8K , 'Value');    h = get(handles.Freq16K , 'Value');        handles.Freq8Knum.String = num2str( g*100 );    all = get(handles.audiovoice , 'Value');    handles.now_audio = all*( a*handles.audio_100 + b*handles.audio_200 + c*handles.audio_500 + d*handles.audio_1K + e*handles.audio_2K + f*handles.audio_4K + g*handles.audio_8K + h*handles.audio_16K );    Audio_ff = abs( fft( handles.now_audio ) );    plot( handles.audio_end , Audio_ff );endguidata(hObject, handles);% Hints: get(hObject,'Value') returns position of slider%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider% --- Executes during object creation, after setting all properties.function Freq8K_CreateFcn(hObject, eventdata, handles)% hObject    handle to Freq8K (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor',[.9 .9 .9]);end% --- Executes on slider movement.function Freq16K_Callback(hObject, eventdata, handles)% hObject    handle to Freq16K (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)try    a = get(handles.Freq100 , 'Value');    b = get(handles.Freq200 , 'Value');    c = get(handles.Freq500 , 'Value');    d = get(handles.Freq1K , 'Value');    e = get(handles.Freq2K , 'Value');    f = get(handles.Freq4K , 'Value');    g = get(handles.Freq8K , 'Value');    h = get(handles.Freq16K , 'Value');        handles.Freq16Knum.String = num2str( h*100 );    all = get(handles.audiovoice , 'Value');    handles.now_audio = all*( a*handles.audio_100 + b*handles.audio_200 + c*handles.audio_500 + d*handles.audio_1K + e*handles.audio_2K + f*handles.audio_4K + g*handles.audio_8K + h*handles.audio_16K );    Audio_ff = abs( fft( handles.now_audio ) );    plot( handles.audio_end , Audio_ff );endguidata(hObject, handles);% Hints: get(hObject,'Value') returns position of slider%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider% --- Executes during object creation, after setting all properties.function Freq16K_CreateFcn(hObject, eventdata, handles)% hObject    handle to Freq16K (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))    set(hObject,'BackgroundColor',[.9 .9 .9]);end% --- Executes during object creation, after setting all properties.function figure1_CreateFcn(hObject, eventdata, handles)% hObject    handle to figure1 (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    empty - handles not created until after all CreateFcns called% --- Executes on button press in play.function play_Callback(hObject, eventdata, handles)% hObject    handle to play (see GCBO)% eventdata  reserved - to be defined in a future version of MATLAB% handles    structure with handles and user data (see GUIDATA)try    sound( handles.now_audio , handles.audioFs );endguidata(hObject, handles);

3 仿真结果

4 参考文献

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

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

举报

相关推荐

0 条评论