Matlab 增量范围

Matlab 增量范围,matlab,indexing,range,increment,Matlab,Indexing,Range,Increment,我不确定是否有一种更简单的方法可以增加一个数字范围,用作索引,以提取12个数字序列中一系列数字的特定范围。例如,我需要一个索引来执行以下操作: Array1是一个由1行612列组成的数组。我需要创建一个索引,以便提取值8、9、10、11和12,然后将它们加12,这样我提取的下一列是20、21、22、23和24,依此类推到ccolumn==612 我的索引将如下所示: index = [ 8 9 10 11 12 20 21 22 23 24 32 33 34 35 36 ] 等至612 我尝试

我不确定是否有一种更简单的方法可以增加一个数字范围,用作索引,以提取12个数字序列中一系列数字的特定范围。例如,我需要一个索引来执行以下操作:

Array1
是一个由1行612列组成的数组。我需要创建一个索引,以便提取值8、9、10、11和12,然后将它们加12,这样我提取的下一列是20、21、22、23和24,依此类推到c
column==612

我的索引将如下所示:

index = [ 8 9 10 11 12 20 21 22 23 24 32 33 34 35 36 ]
等至612


我尝试使用类似于
index=[8:12:12:612]
的方法,但它只提供了
[8 20 32等]

bsxfun
的方法-

array1 = 8:12; %// Starting array
sz = 12; %// Stepsize

Ncols = floor((size(A,2)-array1(1))/sz)+1 %// No. of blocks of indices
ind1 = bsxfun(@plus,array1.',[0:Ncols-1]*sz) %//' Indices in blocks
index = ind1(ind1<=size(A,2)); %// Valid indices
输出-

index =
     1     2     3     4     9    10    11    12    17    18    19    20

然后可以使用这种简单的方法生成索引:

index = find(mod(0:F-1,S)<G)+I-1;
index=find(mod(0:F-1,S)
S = 12;  %// major step (minor step is 1)
G = 5;   %// group size
I = 8;   %// initial value
F = 612; %// ending value
index = find(mod(0:F-1,S)<G)+I-1;