function [hme] = hmeRead (fname) % [hme] = hmeRead (fname) % % Write a HME model to a file. % % INPUTS % fname File name (string). % % OUTPUTS % hme HME model. % % See also hme. % % David Martin % May 2002 % Copyright (C) 2002 David R. Martin % % This program is free software; you can redistribute it and/or % modify it under the terms of the GNU General Public License as % published by the Free Software Foundation; either version 2 of the % License, or (at your option) any later version. % % This program is distributed in the hope that it will be useful, but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU % General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA % 02111-1307, USA, or see http://www.gnu.org/copyleft/gpl.html. [fid,msg] = fopen(fname,'r'); if fid == -1, error(msg); end hme = hmeReadTree(fid); fclose(fid); function [hme] = hmeReadTree(fid) [hme.leaf,count] = fread(fid,1,'int32'); [sz,count] = fread(fid,[1 2],'int32'); [hme.param,count] = fread(fid,sz,'double'); if ~hme.leaf, [n,count] = fread(fid,1,'int32'); hme.children = cell(1,n); for i = 1:n, hme.children{i} = hmeReadTree(fid); end end