function h=error_ellipse(varargin)
% ERROR_ELLIPSE - plot an error ellipse, or ellipsoid, defining confidence region
% ERROR_ELLIPSE(C22) - Given a 2x2 covariance matrix, plot the
% associated error ellipse, at the origin. It returns a graphics handle
% of the ellipse that was drawn.
%
% ERROR_ELLIPSE(C33) - Given a 3x3 covariance matrix, plot the
% associated error ellipsoid, at the origin, as well as its projections
% onto the three axes. Returns a vector of 4 graphics handles, for the
% three ellipses (in the X-Y, Y-Z, and Z-X planes, respectively) and for
% the ellipsoid.
%
% ERROR_ELLIPSE(C,MU) - Plot the ellipse, or ellipsoid, centered at MU,
% a vector whose length should match that of C (which is 2x2 or 3x3).
%
% ERROR_ELLIPSE(...,'Property1',Value1,'Name2',Value2,...) sets the
% values of specified properties, including:
% 'C' - Alternate method of specifying the covariance matrix
% 'mu' - Alternate method of specifying the ellipse (-oid) center
% 'conf' - A value betwen 0 and 1 specifying the confidence interval.
% the default is 0.5 which is the 50% error ellipse.
% 'scale' - Allow the plot the be scaled to difference units.
% 'style' - A plotting style used to format ellipses.
% 'clip' - specifies a clipping radius. Portions of the ellipse, -oid,
% outside the radius will not be shown.
%
% NOTES: C must be positive definite for this function to work properly.
default_properties = struct(...
'C', [], ... % The covaraince matrix (required)
'mu', [], ... % Center of ellipse (optional)
'conf', 0.5, ... % Percent confidence/100
'scale', 1, ... % Scale factor, e.g. 1e-3 to plot m as km
'style', '', ... % Plot style
'clip', inf); % Clipping radius
if length(varargin) >= 1 & isnumeric(varargin{1})
default_properties.C = varargin{1};
varargin(1) = [];
end
if length(varargin) >= 1 & isnumeric(varargin{1})
default_properties.mu = varargin{1};
varargin(1) = [];
end
if length(varargin) >= 1 & isnumeric(varargin{1})
default_properties.conf = varargin{1};
varargin(1) = [];
end
if length(varargin) >= 1 & isnumeric(varargin{1})
default_properties.scale = varargin{1};
varargin(1) = [];
end
if length(varargin) >= 1 & ~ischar(varargin{1})
error('Invalid parameter/value pair arguments.')
end
prop = getopt(default_properties, varargin{:});
C = prop.C;
if isempty(prop.mu)
mu = zeros(length(C),1);
else
mu = prop.mu;
end
conf = prop.conf;
scale = prop.scale;
style = prop.style;
if conf <= 0 | conf >= 1
error('conf parameter must be in range 0 to 1, exclusive')
end
[r,c] = size(C);
if r ~= c | (r ~= 2 & r ~= 3)
error(['Don''t know what to do with ',num2str(r),'x',num2str(c),' matrix'])
end
x0=mu(1);
y0=mu(2);
% Compute quantile for the desired percentile
k = sqrt(qchisq(conf,r)); % r is the number of dimensions (degrees of freedom)
hold_state = get(gca,'nextplot');
if r==3 & c==3
z0=mu(3);
% Make the matrix has positive eigenvalues - else it's not a valid covariance matrix!
if any(eig(C) <=0)
error('The covariance matrix must be positive definite (it has non-positive eigenvalues)')
end
% C is 3x3; extract the 2x2 matricies, and plot the associated error
% ellipses. They are drawn in space, around the ellipsoid; it may be
% preferable to draw them on the axes.
Cxy = C(1:2,1:2);
Cyz = C(2:3,2:3);
Czx = C([3 1],[3 1]);
[x,y,z] = getpoints(Cxy,prop.clip);
h1=plot3(x0+k*x,y0+k*y,z0+k*z,prop.style);hold on
[y,z,x] = getpoints(Cyz,prop.clip);
h2=plot3(x0+k*x,y0+k*y,z0+k*z,prop.style);hold on
[z,x,y] = getpoints(Czx,prop.clip);
h3=plot3(x0+k*x,y0+k*y,z0+k*z,prop.style);hold on
[eigvec,eigval] = eig(C);
[X,Y,Z] = ellipsoid(0,0,0,1,1,1);
XYZ = [X(:),Y(:),Z(:)]*sqrt(eigval)*eigvec';
X(:) = scale*(k*XYZ(:,1)+x0);
Y(:) = scale*(k*XYZ(:,2)+y0);
Z(:) = scale*(k*XYZ(:,3)+z0);
h4=surf(X,Y,Z);
colormap gray
alpha(0.3)
camlight
if nargout
h=[h1 h2 h3 h4];
end
elseif r==2 & c==2
% Make the matrix has positive eigenvalues - else it's not a valid covariance matrix!
if any(eig(C) <=0)
error('The covariance matrix must be positive definite (it has non-positive eigenvalues)')
end
[x,y,z] = getpoints(C,prop.clip);
h1=plot(scale*(x0+k*x),scale*(y0+k*y),prop.style);
set(h1,'zdata',z+1)
if nargout
h=h1;
end
else
error('C (covaraince matrix) must be specified as a 2x2 or 3x3 matrix)')
end
%axis equal
set(gca,'nextplot',hold_state);
%---------------------------------------------------------------
% getpoints - Generate x and y points that define an ellipse, given a 2x2
% covariance matrix, C. z, if requested, is all zeros with same shape as
% x and y.
function [x,y,z] = getpoints(C,clipping_radius)
n=100; % Number of points around ellipse
p=0:pi/n:2*pi; % angles around a circle
[eigvec,eigval] = eig(C); % Compute eigen-stuff
xy = [cos(p'),sin(p')] * sqrt(eigval) * eigvec'; % Transformation
x = xy(:,1);
y = xy(:,2);
z = zeros(size(x));
% Clip data to a bounding radius
if nargin >= 2
r = sqrt(sum(xy.^2,2)); % Euclidian distance (distance from center)
x(r > clipping_radius) = nan;
y(r > clipping_radius) = nan;
z(r > clipping_radius) = nan;
end
%---------------------------------------------------------------
function x=qchisq(P,n)
% QCHISQ(P,N) - quantile of the chi-square distribution.
if nargin<2
n=1;
end
s0 = P==0;
s1 = P==1;
s = P>0 & P<1;
x = 0.5*ones(size(P));
x(s0) = -inf;
x(s1) = inf;
x(~(s0|s1|s))=nan;
for ii=1:14
dx = -(pchisq(x(s),n)-P(s))./dchisq(x(s),n);
x(s) = x(s)+dx;
if all(abs(dx) < 1e-6)
break;
end
end
%---------------------------------------------------------------
function F=pchisq(x,n)
% PCHISQ(X,N) - Probability function of the chi-square distribution.
if nargin<2
n=1;
end
F=zeros(size(x));
if rem(n,2) == 0
s = x>0;
k = 0;
for jj = 0:n/2-1;
k = k + (x(s)/2).^jj/factorial(jj);
end
F(s) = 1-exp(-x(s)/2).*k;
else
for ii=1:numel(x)
if x(ii) > 0
F(ii) = quadl(@dchisq,0,x(ii),1e-6,0,n);
else
F(ii) = 0;
end
end
end
%---------------------------------------------------------------
function f=dchisq(x,n)
% DCHISQ(X,N) - Density function of the chi-square distribution.
if nargin<2
n=1;
end
f=zeros(size(x));
s = x>=0;
f(s) = x(s).^(n/2-1).*exp(-x(s)/2)./(2^(n/2)*gamma(n/2));
%---------------------------------------------------------------
function properties = getopt(properties,varargin)
%GETOPT - Process paired optional arguments as 'prop1',val1,'prop2',val2,...
%
% getopt(properties,varargin) returns a modified properties structure,
% given an initial properties structure, and a list of paired arguments.
% Each argumnet pair should be of the form property_name,val where
% property_name is the name of one of the field in properties, and val is
% the value to be assigned to that structure field.
%
% No validation of the values is performed.
%
% EXAMPLE:
% properties = struct('zoom',1.0,'aspect',1.0,'gamma',1.0,'file',[],'bg',[]);
% properties = getopt(properties,'aspect',0.76,'file','mydata.dat')
% would return:
% properties =
% zoom: 1
% aspect: 0.7600
% gamma: 1
% file: 'mydata.dat'
% bg: []
%
% Typical usage in a function:
% properties = getopt(properties,varargin{:})
% Process the properties (optional input arguments)
prop_names = fieldnames(properties);
TargetField = [];
for ii=1:length(varargin)
arg = varargin{ii};
if isempty(TargetField)
if ~ischar(arg)
error('Propery names must be character strings');
end
f = find(strcmp(prop_names, arg));
if length(f) == 0
error('%s ',['invalid property ''',arg,'''; must be
没有合适的资源?快使用搜索试试~ 我知道了~
hmm-speech-recognition-0.1-(1).zip_speech matlab_speech recognit
共114个文件
wav:105个
m:9个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 66 浏览量
2022-07-14
01:37:50
上传
评论
收藏 837KB ZIP 举报
温馨提示
this is program used for speech recognition
资源推荐
资源详情
资源评论
收起资源包目录
hmm-speech-recognition-0.1-(1).zip_speech matlab_speech recognit (114个子文件)
error_ellipse.m 8KB
Word.m 6KB
Vocabulary.m 2KB
extract_features.m 1KB
normalise.m 861B
mk_stochastic.m 826B
main.m 767B
load_audio_from_folder.m 549B
symmetrize.m 76B
orange11.wav 14KB
orange12.wav 13KB
orange10.wav 13KB
orange07.wav 13KB
orange15.wav 13KB
orange14.wav 12KB
orange13.wav 12KB
orange05.wav 12KB
orange01.wav 12KB
orange06.wav 12KB
orange09.wav 12KB
orange04.wav 12KB
orange08.wav 12KB
orange02.wav 12KB
peach15.wav 12KB
peach12.wav 11KB
peach08.wav 11KB
orange03.wav 11KB
peach02.wav 11KB
peach05.wav 11KB
peach11.wav 11KB
peach06.wav 11KB
peach04.wav 11KB
peach09.wav 10KB
peach13.wav 10KB
peach03.wav 10KB
peach14.wav 10KB
pineapple12.wav 10KB
peach07.wav 10KB
pineapple13.wav 10KB
peach10.wav 10KB
peach01.wav 10KB
pineapple06.wav 9KB
pineapple04.wav 9KB
pineapple14.wav 9KB
pineapple03.wav 9KB
banana13.wav 9KB
banana14.wav 9KB
pineapple01.wav 9KB
pineapple15.wav 9KB
pineapple08.wav 9KB
pineapple02.wav 9KB
pineapple10.wav 9KB
pineapple09.wav 9KB
pineapple07.wav 9KB
banana07.wav 9KB
pineapple11.wav 9KB
pineapple05.wav 9KB
banana10.wav 9KB
banana06.wav 9KB
banana15.wav 8KB
banana05.wav 8KB
banana11.wav 8KB
banana08.wav 8KB
banana12.wav 8KB
banana03.wav 8KB
lime05.wav 7KB
lime03.wav 7KB
lime01.wav 7KB
banana02.wav 7KB
lime12.wav 7KB
lime04.wav 7KB
banana09.wav 7KB
kiwi15.wav 7KB
apple08.wav 7KB
banana04.wav 7KB
kiwi13.wav 7KB
kiwi12.wav 7KB
lime14.wav 7KB
lime06.wav 7KB
lime11.wav 7KB
lime09.wav 7KB
kiwi14.wav 7KB
apple12.wav 7KB
apple11.wav 7KB
apple13.wav 7KB
lime07.wav 7KB
banana01.wav 7KB
kiwi07.wav 7KB
apple09.wav 7KB
apple10.wav 7KB
apple15.wav 7KB
lime15.wav 7KB
kiwi01.wav 7KB
kiwi11.wav 7KB
apple14.wav 7KB
lime02.wav 7KB
lime10.wav 7KB
apple02.wav 6KB
lime08.wav 6KB
apple05.wav 6KB
共 114 条
- 1
- 2
资源评论
JonSco
- 粉丝: 72
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功