Home > NoiseTools > nt_squeeze_all.m

nt_squeeze_all

PURPOSE ^

y=nt_squeeze_all(x) - squeeze structs and cell arrays

SYNOPSIS ^

function y=nt_squeeze_all(x)

DESCRIPTION ^

y=nt_squeeze_all(x) - squeeze structs and cell arrays

  x: object to squeeze
  
  y: result of squeezing

 If x is a struct, all fields and subfields will be concatenated.  If x is
 a cell array, all elements will be concatenated.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function y=nt_squeeze_all(x)
0002 %y=nt_squeeze_all(x) - squeeze structs and cell arrays
0003 %
0004 %  x: object to squeeze
0005 %
0006 %  y: result of squeezing
0007 %
0008 % If x is a struct, all fields and subfields will be concatenated.  If x is
0009 % a cell array, all elements will be concatenated.
0010 
0011 VERBOSE=1;
0012 
0013 x=squeeze(x);
0014 
0015 if isnumeric (x)
0016     y=x;
0017     return;
0018 elseif iscell(x);
0019     if VERBOSE; disp('cell to matrix'); end
0020     try
0021         y=cell2mat(x);
0022     catch
0023         error('could not convert cell array to matrix'); 
0024     end
0025 elseif isstruct(x);
0026     if VERBOSE; disp('struct to cell'); end
0027     try
0028         y=struct2cell(x);
0029     catch
0030         error('could not convert structure to cell array');
0031     end
0032 else
0033     error('!');
0034 end
0035 
0036 y=nt_squeeze_all(y);

Generated on Sat 29-Apr-2023 17:15:46 by m2html © 2005