www.gusucode.com > mbcdesign 工具箱 matlab 源码程序 > mbcdesign/@cset_grid/private/fastind2sub.m
function sub = fastind2sub(siz,ndx) %FASTIND2SUB Multiple subscripts from linear index. % % FASTIND2SUB is used to determine the equivalent subscript values % corresponding to a given single index into an array. % % [I,J] = FASTIND2SUB(SIZ,IND) returns the arrays I and J containing the % equivalent row and column subscripts corresponding to the index matrix % IND for a matrix of size SIZ. % For matrices, [I,J] = FASTIND2SUB(SIZE(A),FIND(A>5)) returns the same % values as [I,J] = FIND(A>5). % % [I1,I2,I3,...,In] = FASTIND2SUB(SIZ,IND) returns N subscript arrays % I1,I2,..,In containing the equivalent N-D array subscripts equivalent % to IND for an array of size SIZ. % Copyright 2000-2005 The MathWorks, Inc. and Ford Global Technologies, Inc. k = [1 cumprod(siz(1:end-1))]; sub = mx_ind2sub(ndx,k(end:-1:1));