What is the best way to create a 10x11 matrix from a 2x100

1 回表示 (過去 30 日間)
Chockalingam Kumar
Chockalingam Kumar 2017 年 8 月 23 日
コメント済み: Chockalingam Kumar 2017 年 8 月 24 日
First column of the 2X100 matrix is a sequence of 10 numbers repeating 10 times. The final matrix required is a 10x11 matrix where first column is the sequence of the 10 numbers that repeat, the remaining 10 columns are the respective numbers from the 2nd column of the original 2x100 matrix

採用された回答

Image Analyst
Image Analyst 2017 年 8 月 23 日
Sounds a lot like homework but I'll take you at your word it's not because you didn't tag it as homework.
first10 = m(1:10, 1);
column2 = reshape(m(:, 2), 10, [])
output = [first10, column2]
where m is your 100 by 2 matrix.
  1 件のコメント
Chockalingam Kumar
Chockalingam Kumar 2017 年 8 月 24 日
Thank you. I am using this method.

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

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2017 年 8 月 23 日
Let A - your matrix [100 x 2]
b = sortrows(A);
out = [unique(b(:,1)), reshape(b(:,2),[],10)];
  1 件のコメント
Chockalingam Kumar
Chockalingam Kumar 2017 年 8 月 24 日
thank you for your reply. It works.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by