Code covered by the BSD License  

Highlights from
Statistical Learning Toolbox

from Statistical Learning Toolbox by Dahua Lin
Functions for statistical learning, pattern recognition and computer vision, covering many topics.

Description of slreadarray
Home > sltoolbox > fileio > slreadarray.m

slreadarray

PURPOSE ^

SLREADARRAY Reads an array from an array file

SYNOPSIS ^

function A = slreadarray(filename)

DESCRIPTION ^

SLREADARRAY Reads an array from an array file

 $ Syntax $
   - A = slreadarray(filename)

 $ Arguments $
   - filename:         the filename of the array file
   - A:                the array read

 $ Description $
   - A = slreadarray(filename) reads an array from an array file and
     returns it by A.

 $ History $
   - Created by Dahua Lin, on Jul 26th, 2006

CROSS-REFERENCE INFORMATION ^

This function calls:
This function is called by:
  • slsumstat_blks SLSUMSTAT_BLKS Sums up statistics on all blocks for partitioned data
  • slverifyroc_blks SLVERIFYROC_BLKS Computes the verification ROC for blockwise score matrix
  • sl2dmatcov SL2DMATCOV Computes the 2D matrix-covariances
  • sl2dpca_apply SL2DPCA_APPLY Applies 2D PCA onto a set of matrices to extract features
  • sl2dpcaex SL2DPCAEX Learns Extended 2D PCA on a set of matrix samples
  • slarrmean SLARRMEAN Computes the mean of a set of arrays
  • slpartitionpca SLPARTITIONPCA Performs Partition-based PCA and saves the models
  • slpartitionpca_apply SLPARTITIONPCA_APPLY applies partition-based PCA to a set of arrays
  • slpartitionpca_construct SLPARTITIONPCA_CONSTRUCT Constructs the array from features
  • slclassify_blks SLCLASSIFY_BLKS Classifies samples according to blockwise scores

SOURCE CODE ^

0001 function A = slreadarray(filename)
0002 %SLREADARRAY Reads an array from an array file
0003 %
0004 % $ Syntax $
0005 %   - A = slreadarray(filename)
0006 %
0007 % $ Arguments $
0008 %   - filename:         the filename of the array file
0009 %   - A:                the array read
0010 %
0011 % $ Description $
0012 %   - A = slreadarray(filename) reads an array from an array file and
0013 %     returns it by A.
0014 %
0015 % $ History $
0016 %   - Created by Dahua Lin, on Jul 26th, 2006
0017 %
0018 
0019 value_types = { ...
0020     'double', ...
0021     'single', ...
0022     'logical', ...
0023     'char', ...
0024     'int8', ...
0025     'uint8', ...
0026     'int16', ...
0027     'uint16', ...
0028     'int32', ...
0029     'uint32', ...
0030     'int64', ...
0031     'uint64'};
0032 
0033 %% open file
0034 fid = fopen(filename, 'r');
0035 if fid <= 0
0036     error('sltoolbox:filefail', ...
0037         'Fail to open file %s', filename);
0038 end
0039 
0040 
0041 %% read header
0042 
0043 % read and verify tag
0044 tag = fread(fid, 4, '*char')';
0045 if ~isequal(tag, ['arr', 0])
0046     error('sltoolbox:parseerror', ...
0047         'The file tag is invalid');
0048 end
0049 
0050 % read the value type
0051 typeidx = fread(fid, 1, 'uint8');
0052 valtype = value_types{typeidx};
0053 
0054 % read the dimension
0055 d = fread(fid, 1, 'uint8');
0056 
0057 %% read size
0058 
0059 fseek(fid, 8, -1);
0060 siz = fread(fid, d, 'uint32')';
0061 
0062 
0063 %% read data
0064 A = fread(fid, prod(siz), ['*', valtype]);
0065 if length(siz) == 1
0066     siz = [siz, 1];
0067 end
0068 A = reshape(A, siz);
0069 
0070 
0071 %% close file
0072 fclose(fid);
0073 
0074 
0075 
0076 
0077 
0078 
0079 
0080 
0081 
0082 
0083

Generated on Wed 20-Sep-2006 12:43:11 by m2html © 2003

Contact us at files@mathworks.com