1 简介 【信号处理】手机拨号音效模拟含Matlab源码 2 部分代码 function varargout = tul(varargin) % TUL MATLAB code for tul.fig % TUL, by itself, creates a new TUL or raises the existing % singleton*. % % H = TUL returns
1 简介
【信号处理】手机拨号音效模拟含Matlab源码
2 部分代码
function varargout = tul(varargin)% TUL MATLAB code for tul.fig
% TUL, by itself, creates a new TUL or raises the existing
% singleton*.
%
% H = TUL returns the handle to a new TUL or the handle to
% the existing singleton*.
%
% TUL('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in TUL.M with the given input arguments.
%
% TUL('Property','Value',...) creates a new TUL or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before tul_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to tul_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help tul
% Last Modified by GUIDE v2.5 09-May-2021 18:33:50
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @tul_OpeningFcn, ...
'gui_OutputFcn', @tul_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 tul is made visible.
function tul_OpeningFcn(hObject, eventdata, handles, varargin)
% 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 tul (see VARARGIN)
% Choose default command line output for tul
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes tul wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = tul_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% 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 pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=[1:1000];
d1=sin(0.5343*n)+sin(0.9268*n);
n1=strcat(get(handles.edit1,'string'),'1');
set(handles.edit1,'string',n1);
space=zeros(1,100);
global NUM
phone=[NUM,d1];
NUM=[phone,space];
sound(d1,8192);
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=[1:1000];
d2=sin(0.5343*n)+sin(1.024*n);
n2=strcat(get(handles.edit1,'string'),'2');
set(handles.edit1,'string',n2);
space=zeros(1,100);
global NUM
phone=[NUM,d2];
NUM=[phone,space];
sound(d2,8192);
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=[1:1000];
d3=sin(0.5343*n)+sin(1.1323*n);
n3=strcat(get(handles.edit1,'string'),'3');
set(handles.edit1,'string',n3);
space=zeros(1,100);
global NUM
phone=[NUM,d3];
NUM=[phone,space];
sound(d3,8192);
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=[1:1000];
d4=sin(0.59033*n)+sin(0.9268*n);
n4=strcat(get(handles.edit1,'string'),'4');
set(handles.edit1,'string',n4);
space=zeros(1,100);
global NUM
phone=[NUM,d4];
NUM=[phone,space];
sound(d4,8192);
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=[1:1000];
d5=sin(0.59033*n)+sin(1.024*n);
n5=strcat(get(handles.edit1,'string'),'5');
set(handles.edit1,'string',n5);
space=zeros(1,100);
global NUM
phone=[NUM,d5];
NUM=[phone,space];
sound(d5,8192);
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=[1:1000];
d6=sin(0.59033*n)+sin(1.1323*n);
n6=strcat(get(handles.edit1,'string'),'6');
set(handles.edit1,'string',n6);
space=zeros(1,100);
global NUM
phone=[NUM,d6];
NUM=[phone,space];
sound(d6,8192);
% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=[1:1000];
d7=sin(0.6531*n)+sin(0.9268*n);
n7=strcat(get(handles.edit1,'string'),'7');
set(handles.edit1,'string',n7);
space=zeros(1,100);
global NUM
phone=[NUM,d7];
NUM=[phone,space];
sound(d7,8192);
% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=[1:1000];
d8=sin(0.6531*n)+sin(1.024*n);
n8=strcat(get(handles.edit1,'string'),'8');
set(handles.edit1,'string',n8);
space=zeros(1,100);
global NUM
phone=[NUM,d8];
NUM=[phone,space];
sound(d8,8192);
% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=[1:1000];
d9=sin(0.6531*n)+sin(1.1323*n);
n9=strcat(get(handles.edit1,'string'),'9');
set(handles.edit1,'string',n9);
space=zeros(1,100);
global NUM
phone=[NUM,d9];
NUM=[phone,space];
sound(d9,8192);
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (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 edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (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 button press in pushbutton10.
function pushbutton10_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=[1:1000];
num=handles.edit1,'string';
l=length(num);
n11=strrep(num,num,num(1:l-1));
d11=sin(0.7217*n)+sin(0.9273*n);
set(handles.edit1,'string',n11);
global NUM
L=length(NUM);
NUM=NUM(1:L-1100);
sound(d11,8192);
% --- Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
n=[1:1000];
d0=sin(0.7217*n)+sin(1.0247*n);
n0=strcat(get(handles.edit1,'string'),'0');
set(handles.edit1,'string',n0);
space=zeros(1,100);
global NUM
phone=[NUM,d0];
NUM=[phone,space];
sound(d0,8192);
% --- Executes on button press in pushbutton12.
function pushbutton12_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global NUM
sound(NUM,8192);
L=length(NUM);
n=L/1100;
number='';
for i=1:n
j=(i-1)*1100+1;
d=NUM(j:j+999);
f=fft(d,2048);
a=abs(f);
p=a.*a/10000;
num(1)=find(p(1:250)==max(p(1:250)));
num(2)=300+find(p(300:380)==max(p(300:380)));
if(num(1)<180)
row=1;
elseif (num(1)<200)
row=2;
elseif (num(1)<220)
row=3;
else
row=4;
end
if(num(2)<320)
column=1;
elseif(num(2)<340)
column=2;
else
column=3;
end
z=[row,column];
if z==[4,2]
tel=0;
elseif z==[1,1]
tel=1;
elseif z==[1,2]
tel=2;
elseif z==[1,3]
tel=3;
elseif z==[2,1]
tel=4;
elseif z==[2,2]
tel=5;
elseif z==[2,3]
tel=6;
elseif z==[3,1]
tel=7;
elseif z==[3,2]
tel=8;
elseif z==[3,3]
tel=9;
end
t(i)=tel;
c=strcat(number,int2str(tel));
number=c;
i=i+1;
end
3 仿真结果
4 参考文献
[1]李强, 明艳, 陈前斌,等. 基于Matlab的数字信号处理实验仿真系统的实现[J]. 实验技术与管理, 2006(05):91-93+124.