comparison toolboxes/FullBNT-1.0.7/KPMtools/subv2ind.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:cc4b1211e677
1 function index = subv2ind(siz,sub)
2 %SUBV2IND Linear index from subscript vector.
3 % SUBV2IND(SIZ,SUB) returns an equivalent single index corresponding to a
4 % subscript vector for an array of size SIZ.
5 % If SUB is a matrix, with subscript vectors as rows, then the result is a
6 % column vector.
7 %
8 % This is the opposite of IND2SUBV, so that
9 % SUBV2IND(SIZ,IND2SUBV(SIZ,IND)) == IND.
10 %
11 % See also IND2SUBV, SUB2IND.
12
13 %index = subv2indTest(siz,sub);
14 prev_cum_size = [1 cumprod(siz(1:end-1))];
15 %index = (sub-1)*prev_cum_size' + 1;
16 index = sub*prev_cum_size' - sum(prev_cum_size) + 1;
17