www.pudn.com > duandianjiance.rar > signal.m


function varargout = signal(varargin) 
% SIGNAL M-file for signal.fig 
%      SIGNAL, by itself, creates a new SIGNAL or raises the existing 
%      singleton*. 
% 
%      H = SIGNAL returns the handle to a new SIGNAL or the handle to 
%      the existing singleton*. 
% 
%      SIGNAL('CALLBACK',hObject,eventData,handles,...) calls the local 
%      function named CALLBACK in SIGNAL.M with the given input arguments. 
% 
%      SIGNAL('Property','Value',...) creates a new SIGNAL or raises the 
%      existing singleton*.  Starting from the left, property value pairs are 
%      applied to the GUI before signal_OpeningFunction gets called.  An 
%      unrecognized property name or invalid value makes property application 
%      stop.  All inputs are passed to signal_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 signal 
 
% Last Modified by GUIDE v2.5 11-May-2006 15:33:30
 
% Begin initialization code - DO NOT EDIT 
gui_Singleton = 1; 
gui_State = struct('gui_Name',       mfilename, ... 
                   'gui_Singleton',  gui_Singleton, ... 
                   'gui_OpeningFcn', @signal_OpeningFcn, ... 
                   'gui_OutputFcn',  @signal_OutputFcn, ... 
                   'gui_LayoutFcn',  [] , ... 
                   'gui_Callback',   []); 
if nargin & isstr(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 signal is made visible. 
function signal_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 signal (see VARARGIN) 
 
% Choose default command line output for signal 
handles.output = hObject; 
 
% Update handles structure 
guidata(hObject, handles); 
 
% UIWAIT makes signal wait for user response (see UIRESUME) 
% uiwait(handles.figure1); 
 
 
% --- Outputs from this function are returned to the command line. 
function varargout = signal_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) 
 
a=wavread('neng.wav'); 
figure(1); 
plot(a);


% --- 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)
 
a=wavread('neng.wav'); 
n=length(a); 
N=320; 
figure(2); 
subplot(3,1,1),plot(a); 
h=linspace(1,1,N);%形成一个矩形窗,长度为N 
En=conv(h,a.*a);%求卷积得其短时能量函数En 
subplot(3,1,2),plot(En); 
b=[]; 
b(1)=0; 
for i=2:n 
  if a(i)*a(i-1)>0 
      b(i)=0; 
  else 
      b(i)=1; 
  end 
end 
w=[]; 
w(1:N-1)=0; 
for i=N:n 
 w(i)=0; 
  for j=i-N+1:i 
   w(i)=w(i)+b(j); 
  end 
 w(i)=w(i)/N;  
end 
 
subplot(3,1,3),plot(w); 

% --- 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) 
a=wavread('neng.wav'); 
n=length(a); 
N=320; 
d=[]; 
 
for i=0:N-1 
  d(i+1)=0; 
  for j=1000-N+1:1000-i 
  d(i+1)=d(i+1)+a(j)*a(j+i); 
  end 
end  
 
figure(3); 
plot(d);