Home > chronux_1_1 > spikesort > utility > datatypes > structindex.m

structindex

PURPOSE ^

STRUCTINDEX Indexes each field in a structure of arrays.

SYNOPSIS ^

function structure = structindex(structure, index)

DESCRIPTION ^

STRUCTINDEX       Indexes each field in a structure of arrays.
   STRUCTOUT = STRUCTINDEX(STRUCTIN, INDEX) takes a structure STRUCTIN
   in which every field is a cell or numeric array and returns a
   structure with the same fields with the data rearranged according to:
                STRUCTOUT.FIELD1 = STRUCTIN.FIELD1(INDEX).

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function structure = structindex(structure, index)
0002 %STRUCTINDEX       Indexes each field in a structure of arrays.
0003 %   STRUCTOUT = STRUCTINDEX(STRUCTIN, INDEX) takes a structure STRUCTIN
0004 %   in which every field is a cell or numeric array and returns a
0005 %   structure with the same fields with the data rearranged according to:
0006 %                STRUCTOUT.FIELD1 = STRUCTIN.FIELD1(INDEX).
0007 
0008 fields = fieldnames(structure); 
0009 for f = 1:length(fields)
0010     structure.(fields{f}) = structure.(fields{f})(index);
0011 end

Generated on Sun 13-Aug-2006 11:49:44 by m2html © 2003