2017-02-26 135 views
-1

我有一個名爲eta(54×1800)的矩陣。對於選擇具體的行和列一般我們使用:如何從矩陣中選擇選擇性指標基準列?

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

但在這裏,我需要選擇連續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]); 

但它並沒有給連續列的結果。

+1

您能正確格式化您的文章嗎?很難閱讀這段文字。 – Adriaan

回答

1

如果你的第一個指標是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 
+0

@感謝Sardar usama,Andriaan和M usman, –

0

試試這個

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