from
structindex
by AJ Johnson
Two mex files: structindex selects elements from all fields of a structure ....
|
| structindex.m |
%STRUCTINDEX Extract data elements from a structure of arrays.
% STRUCTINDEX(S,INDEX) returns selected data elements from each field
% of S. The returned value has all the same fields as S, and each field
% will have as many elements as are in INDEX. INDEX is an array of
% indecies to select. If a given index does not exist for a particular
% field of S, a default value for the data element is used.
%
% Currently, indexing in one-dimensional only (fields having data of two
% or more dimensions are not supported). Also, indexing through the use
% use of logical arrays is not supported at this time.
%
% EXAMPLES:
% s.name = {'sam','mike','john'};
% s.income = [10000,90000,-10];
% structindex(s,2:3)
% ans =
% name: {'mike' 'john'}
% income: [90000 -10]
% structindex(s,[2 2 2 99])
% Warning: Index vector contained values exceeding structure field sizes
% ans =
% name: {'mike' 'mike' 'mike' []}
% income: [90000 90000 90000 0]
%
% See also STRUCTCAT.
|
|
Contact us at files@mathworks.com