(Turn from) http://wenku.baidu.com/view/1d55480fbe1e650e52ea99a3.html
%filename:manwoman.m
%different mans from Woman.
%===========================================================
Clear
% [X,fs,bits]=wavread (' D.wav ', [1 5000]); % read-in sound file (*.wav)
[X,fs,bits]=wavread (' d.wav ', [5000 10944]); % read-in sound file (*.wav)
Sound (x,fs,bits); % data converted to sound by sound card
%===========================================================
% Pause;
Data1=x (:, 1);
N=0:length (x)-1;
time=n/fs;
Subplot (3,1,1)% draw 1th Sub-graph of 2 rows 1 columns
Plot (time,data1)% with time on the horizontal axis, the data for the longitudinal axes of the drawing
Xlabel (' Time (sec) ')% label horizontal
Ylabel (' Signal level (Volts) ')% callout ordinate
Grid on% Add mesh
% Pause;
% of data collected for filtering processing
BlockSize =length (DATA1); % Calculation window function length
window = Hanning (blocksize); % Calculate Henning window function (this function is Matlab comes with)
Data2=window.*data1; % data is first added to window processing
% wp=[70,400]; %100hz--400hz
% Wp=wp*2/fs;
wp=3000*2/fs;
[B,a]=ellip (4,0.1,20,WP); % Constructed ellipse filter
Data=filter (B,A,DATA2); % to find the response of the filter after the window processing data
Subplot (3,1,2)% draw 1th Sub-graph of 2 rows 1 columns
Plot (Time,data)% with time on the horizontal axis, the data for the longitudinal axes of the drawing
Xlabel (' Time (sec) ')% label horizontal
%ylabel (' Signal level (Volts) ')% callout ordinate
Grid on% Add mesh
% Pause;
[Xmax,index]=max (DATA1);
Timewin=floor (0.015*FS);
Xwin=data1 (Index-timewin:index+timewin);
[Y,lags]=xcov (Xwin);
Subplot (3,1,3)
Plot (Lags,y)
Grid on
Ylen=length (y);
halflen= (ylen+1)/2 +30;
Yy=y (Halflen:ylen);
[Ymax,maxindex] = max (yy);
fmax=fs/(MAXINDEX+30);
Disp ([' Maximum occurred at ', Num2str (Fmax), ' Hz ')
F=fmax;
Justify=f; %hz
If justify<180%limithz The following judgment is male
Display ' Man '
Else
Display ' Women '
End
Using MATLAB to judge male and female voices