如何 select select 从矩阵中获取索引基列?

How to select selective indices base column from matrix?

我有一个名为 eta (54×1800) 的矩阵。对于 select 特定的行和列,我们通常使用:

result = eta(:, 86:90:1800);

但这里我需要 select 连续 5 列 86,87,88,89,90 每个都有差异 90。例如在 86, 87, 88, 89, 90 之后,我想得到 176, 177, 178, 179, 180

我试过这个:

result=eta(:,[86:90:1800,87:90:1800,88:90:1800,89:90:1800,90:90:1800]); 

但是没有给出连续列的结果

试试这个

mat=rand(54,1800); %your eta matrix
mywish=[86:1:90]; %your wish to select consective columns
for i=1:length(mywish)
    results=mat(:,mywish(i):90:1800) %getting the column interval 90
end

如果你的第一个索引是a(=86),要提取的区域结束是b(=1800),差值是d(=90),那么你会做:

s = a:d:b; % create all start indices
k = cumsum([s; ones(4,numel(s))],1) % compute all consecutive indices
result = eta(:,k(:)); % exctract all indeces using linear index for the column subscript