I have a data set of 400 columns and 644rows .I need to select columns 1,2,11,12,​21,22,....​.381,382,3​91,392 or move these particular columns in to a matrix.how can i write code for this in matlab

1 回表示 (過去 30 日間)
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20. from this columns i need to select 1,2,11,12 columns in to one matrix and the remaining in to another matrix. 20 is just an example..i want the answer for 400 columns and 644 rows.

採用された回答

Roger Stafford
Roger Stafford 2016 年 3 月 30 日
If M is the matrix with 400 columns, and if M2 is the matrix to be obtained from it, do this:
n = 400;
M2 = M(:,mod((1:n)-1,10)<=1);
  2 件のコメント
Sindhu  Reddy
Sindhu Reddy 2016 年 3 月 30 日
thanks how to copy the remaining columns in to another matrix.say from 3 to 10,13 to 20...393 to 400.
Roger Stafford
Roger Stafford 2016 年 3 月 30 日
n = 400;
M2 = M(:,mod((1:n)-1,10)<=1); % <-- Into one matrix
M3 = M(:,mod((1:n)-1,10)>=2); % <-- Into the other matrix

サインインしてコメントする。

その他の回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 3 月 30 日
編集済み: Azzi Abdelmalek 2016 年 3 月 30 日
A=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
idx=[1,2,11,12]
out1=A(idx)
out2=A(setdiff(1:numel(A),idx))
  2 件のコメント
Sindhu  Reddy
Sindhu Reddy 2016 年 3 月 30 日
i have400 columns.i just gave example of 20.i can't list 400 numbers in A matrix
Azzi Abdelmalek
Azzi Abdelmalek 2016 年 3 月 30 日
Who said to list to list the 400 elements?

サインインしてコメントする。


MHN
MHN 2016 年 3 月 30 日
編集済み: MHN 2016 年 3 月 30 日
A = 1:20;
M1 = A([1,2,11,12]);
M2 = setdiff(A,M1);

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by