Nindex

From Eigenvector Documentation Wiki
Jump to: navigation, search

Contents

Purpose

Generic subscript indexing for n-way arrays.

Synopsis

x = nindex(x,indices,modes)

Description

NINDEX allows indexing into an n-way array without concern to the actual number of modes in the array. Requires n-way array (x) a cell of requested indices (indices) (e.g. {[1:5] [10:20]} ) and the modes to which those indicies should be applied (modes). Any additional modes not specified in (indices) will be returned as if reffered to as ':' and returned in full. If (modes) omitted, it is assumed that indices should refer to the first modes of (x) up to the length of (indices).

Examples

x = nindex(x,{1:5});      %extract indices 1:5 from mode 1 (rows) of any n-way array
x = nindex(x,{1:5},3);    %extract indices 1:5 from mode 3 of any n-way array 
x = nindex(x,{1:10 1:5},[5 8]);  %extract 1:10 from mode 5 and 1:5 from mode 8
x = nindex(x,{1:10 1:5});  %extract 1:10 from mode 1 and 1:5 of mode 2
 
%The last example is equivalent to performing:
x = x(1:10,1:5);          %for a 2-way array or
x = x(1:10,1:5,:,:,:);    %for a 5-way array
% Note, the use cell notation can be omitted on indices if only one mode is
% being indexed:  
x = nindex(x,5:10,3);  %is valid


See Also

nassign

Views
Personal tools