⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gmmread.m

📁 一个关于数据聚类和模式识别的程序,在生物化学,化学中因该都可以用到.希望对大家有用,谢谢支持
💻 M
字号:
function gmm=gmmRead(gmmFile)
%gmmRead: Read GMM from a file
%	Usage: gmm=gmmRead(gmmFile)
%		gmm: gmm structure
%		gmmFile: output file
%
%	For example:
%		gmm=gmmRead('example.gmm');

%	Roger Jang, 20070903

fid=fopen(gmmFile, 'r');

% ====== Read comments
target='<comment>';
line=fgetl(fid);
if strcmp(line, target)==0, fprintf('line=%s\n', line); error('Cannot find "%s"!\n', target); end
line=fgetl(fid);
gmm.comment=line;
% ====== Read version
target='<version>';
line=fgetl(fid);
if strcmp(line, target)==0, fprintf('line=%s\n', line); error('Cannot find "%s"!\n', target); end
line=fgetl(fid);
gmm.version=line;
% ====== Read gmmType
target='<gmmType>';
line=fgetl(fid);
if strcmp(line, target)==0, fprintf('line=%s\n', line); error('Cannot find "%s"!\n', target); end
line=fgetl(fid);
gmm.gmmType=eval(line);
% ====== Read name
target='<name>';
line=fgetl(fid);
if strcmp(line, target)==0, fprintf('line=%s\n', line); error('Cannot find "%s"!\n', target); end
line=fgetl(fid);
gmm.name=line;
% ====== Read dim
target='<dim>';
line=fgetl(fid);
if strcmp(line, target)==0, fprintf('line=%s\n', line); error('Cannot find "%s"!\n', target); end
line=fgetl(fid);
gmm.dim=eval(line);
% ====== Read mixNum
target='<mixNum>';
line=fgetl(fid);
if strcmp(line, target)==0, fprintf('line=%s\n', line); error('Cannot find "%s"!\n', target); end
line=fgetl(fid);
gmm.mixNum=eval(line);
% ====== Read mean
target='<mean>';
line=fgetl(fid);
if strcmp(line, target)==0, fprintf('line=%s\n', line); error('Cannot find "%s"!\n', target); end
for i=1:gmm.mixNum
	line=fgetl(fid);
	gmm.mean(:,i)=eval(['[', line, ']']);
end
% ====== Read covariance
target='<covariance>';
line=fgetl(fid);
if strcmp(line, target)==0, fprintf('line=%s\n', line); error('Cannot find "%s"!\n', target); end
line=fgetl(fid);
gmm.covariance=eval(['[', line, ']']);
% ====== Read weight
target='<weight>';
line=fgetl(fid);
if strcmp(line, target)==0, fprintf('line=%s\n', line); error('Cannot find "%s"!\n', target); end
line=fgetl(fid);
gmm.weight=eval(['[', line, ']']);
% ====== Read gConst
target='<gConst>';
line=fgetl(fid);
if strcmp(line, target)==0, fprintf('line=%s\n', line); error('Cannot find "%s"!\n', target); end
line=fgetl(fid);
gmm.gConst=eval(['[', line, ']']);
fclose(fid);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -