Home > m > helper > ltpda_structidx.m

ltpda_structidx

PURPOSE ^

LTPDA_STRUCTIDX Index a structure. All fields are assumed to be vectors of the

SYNOPSIS ^

function sout = ltpda_structidx(sin, idx, varargin)

DESCRIPTION ^

 LTPDA_STRUCTIDX Index a structure. All fields are assumed to be vectors of the
 same length, except those explicitely ignored.
 
 function sout = ltpda_structidx(sin, idx)
               = ltpda_structidx(sin, idx, 'field1', 'field2')
 
 You can give an additional list of field names which will be ignored in
 the indexing.
 
 M Hewitson 26-01-07
 
 $Id: ltpda_structidx.html,v 1.1 2007/06/08 14:15:10 hewitson Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function sout = ltpda_structidx(sin, idx, varargin)
0002 
0003 % LTPDA_STRUCTIDX Index a structure. All fields are assumed to be vectors of the
0004 % same length, except those explicitely ignored.
0005 %
0006 % function sout = ltpda_structidx(sin, idx)
0007 %               = ltpda_structidx(sin, idx, 'field1', 'field2')
0008 %
0009 % You can give an additional list of field names which will be ignored in
0010 % the indexing.
0011 %
0012 % M Hewitson 26-01-07
0013 %
0014 % $Id: ltpda_structidx.html,v 1.1 2007/06/08 14:15:10 hewitson Exp $
0015 
0016 Nigf = nargin-2;
0017 
0018 % examine fields
0019 fields = fieldnames(sin);
0020 nf     = length(fields);
0021 
0022 for f=1:nf
0023   fn = char(fields(f));
0024   skip = 0;
0025   for j=1:Nigf
0026     
0027     if strcmp(fn, char(varargin{j}))
0028       skip = 1;
0029       str = sprintf('sout.%s = sin.%s;', fn, fn);
0030       eval(str);
0031     end
0032     
0033   end
0034     
0035   if ~skip
0036     str = sprintf('sout.%s = sin.%s(idx);', fn, fn);
0037     eval(str);
0038   end
0039 end
0040 
0041 
0042 
0043 
0044 
0045 % END

Generated on Fri 08-Jun-2007 16:09:11 by m2html © 2003