数字信号处理课程设计.(3)

2018-12-17 10:51

哪一个。

if ( Fout > temp )

number = n; temp = Fout; end end

% DesignLowerFilter.m

function B = DesignLowerFilter(Wo)

fs = 8000; N = 400; k = 2*pi/fs; Bandwidth = 70; wc1 = ( Wo - Bandwidth / 2 ) * k; wc2 = ( Wo + Bandwidth / 2 ) * k; B = fir2(N,[0,wc1/pi,wc2/pi,1],[0,1,1,0]);

高频滤波器源程序: % FindHigherFreq.m

function number = FindHigherFreq(Signal) Freq = [1209,1336,1447]; temp = 0; for n = 1:length(Freq)

Wo = Freq(n); B = DesignHigherFilter(Wo); Out = filter(B,1,Signal); Fout = max(abs(fft(Out))); if ( Fout > temp )

number = n; temp = Fout; end end

% DesignHigherFilter.m

function B = DesignHigherFilter(Wo)

11

fs = 8000; N = 200; k = 2*pi/fs; Bandwidth = 110; wc1 = ( Wo - Bandwidth / 2 ) * k; wc2 = ( Wo + Bandwidth / 2 ) * k; B = fir2(N,[0,wc1/pi,wc2/pi,1],[0,1,1,0]);

(4)编写接收DTMF信号的函数,并显示解码结果,即按键数字。 源程序如下:

% --- Executes on button press in DeCode.

function DeCode_Callback(hObject, eventdata, handles) % hObject handle to DeCode (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)

handles.DecodeTelNumber=''; %清空解码字符串变量,开始新一轮解码。 keys = ['1','2','3';'4','5','6';'7','8','9';'*','0','#']; for i=1 : length(handles.TelNumber) Signal = dtmf(handles.TelNumber(i)); RowNumber = FindLowerFreq(Signal); ColumnNumber = FindHigherFreq(Signal); ResultKey = keys(RowNumber,ColumnNumber);

handles.DecodeTelNumber=strcat(handles.DecodeTelNumber,ResultKey); set(handles.DecodeText,'string',handles.DecodeTelNumber); end

handles.TelNumber=''; %解码完成后,拨号变量清空,方便下一次拨号。

% Update handles structure guidata(hObject, handles);

% RowNumber = FindLowerFreq(handles.DTMFSignal); % ColumnNumber = FindHigherFreq(handles.DTMFSignal); % ResultKey = keys(RowNumber,ColumnNumber);

12

% set(handles.DecodeText,'string',char(ResultKey));

(5)设计拨号键盘、电话号码显示、时域和频域波形显示的用户图形界面,并控制完整的拨号、识别过程。

源程序如下:

unction varargout = DTMFSystem(varargin) % DTMFSYSTEM M-file for DTMFSystem.fig

% Begin initialization code gui_Singleton = 1;

gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ...

'gui_OpeningFcn', @DTMFSystem_OpeningFcn, ... 'gui_OutputFcn', @DTMFSystem_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1})

gui_State.gui_Callback = str2func(varargin{1}); end if 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 DTMFSystem is made visible.

function DTMFSystem_OpeningFcn(hObject, eventdata, handles, varargin)

13

% This function has no output args, see OutputFcn. % hObject handle to figure

% 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 DTMFSystem (see VARARGIN)

% Choose default command line output for DTMFSystem handles.output = hObject;

handles.DTMFSignal = [];

handles.TelNumber='';

handles.DecodeTelNumber='';%保存解码字符串 变量

set(gcf,'CurrentAxes',handles.TimeFig); xlabel('单位:(s)');

set(gcf,'CurrentAxes',handles.FrequencyFig); xlabel('单位:(Hz)');

% Update handles structure guidata(hObject, handles);

% UIWAIT makes DTMFSystem wait for user response (see UIRESUME) % uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.

function varargout = DTMFSystem_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT);

14

% hObject handle to figure

% 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 structure varargout{1} = handles.output;

% --- Executes on button press in Key1.

function Key1_Callback(hObject, eventdata, handles) % hObject handle to Key1 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(handles.DecodeText,'string',''); %清空解码显示文本框

Signal = PressKeyDown(handles,'1'); handles.DTMFSignal = Signal;

handles.TelNumber=strcat(handles.TelNumber,'1'); % Update handles structure guidata(hObject, handles);

set(handles.CodeText,'string',handles.TelNumber);

% --- Executes on button press in Key2.

function Key2_Callback(hObject, eventdata, handles) % hObject handle to Key2 (see GCBO)

% eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) set(handles.DecodeText,'string',''); %清空解码显示文本框

15


数字信号处理课程设计.(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:盐津县永丰矿业有限公司永丰煤矿整合技改施工组织设计

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: