Reads a Tensor4 from an XML file. Internal function that should never be called directly. Use *xmlLoad* instead. FORMAT result = xmlReadTensor4(fid, attrlist, itype, ftype, binary, fid2) OUT result Tensor4 IN fid File descriptor of XML file IN attrlist List of tag attributes IN itype Integer type of input file IN ftype Floating point type of input file IN binary Flag. 1 = binary file, 0 = ascii IN fid2 File descriptor of binary file
0001 % Reads a Tensor4 from an XML file. 0002 % 0003 % Internal function that should never be called directly. 0004 % Use *xmlLoad* instead. 0005 % 0006 % FORMAT result = xmlReadTensor4(fid, attrlist, itype, ftype, binary, fid2) 0007 % 0008 % OUT result Tensor4 0009 % IN fid File descriptor of XML file 0010 % IN attrlist List of tag attributes 0011 % IN itype Integer type of input file 0012 % IN ftype Floating point type of input file 0013 % IN binary Flag. 1 = binary file, 0 = ascii 0014 % IN fid2 File descriptor of binary file 0015 0016 % 2002-10-18 Created by Oliver Lemke. 0017 0018 function result = xmlReadTensor4(fid, attrlist, itype, ftype, binary, fid2) 0019 0020 nb = str2num (xmlGetAttrValue (attrlist, 'nbooks')); 0021 np = str2num (xmlGetAttrValue (attrlist, 'npages')); 0022 nr = str2num (xmlGetAttrValue (attrlist, 'nrows')); 0023 nc = str2num (xmlGetAttrValue (attrlist, 'ncols')); 0024 nelem = nb * np * nr * nc; 0025 0026 if ~binary 0027 result = fscanf (fid, '%f', nelem); 0028 else 0029 result = fread (fid2, nelem, ftype); 0030 end 0031 xmlCheckSize (nelem, size (result)); 0032 0033 result = permute (reshape (result, [nc nr np nb]), [4 3 2 1]); 0034