split the matrix into two

5 ビュー (過去 30 日間)
Berfin Çetinkaya
Berfin Çetinkaya 2022 年 3 月 29 日
コメント済み: Berfin Çetinkaya 2022 年 3 月 29 日
Hello everyone
I have a matrix. And I want to split this matrix into two matrices, but there's a rule.
It needs to get 1,3,5 columns to create the first matrix. It needs to get columns 2,4,6 .. to create the second matrix. (My real matrix is a very large 50x138 matrix, but I'll show it with a small example.)
Sample :
1 4 8 7 5 9
2 7 5 6 4 3
8 7 6 5 5 1
new A matrix :
1 8 5
2 5 4
8 6 5
new B matrix :
4 7 9
7 6 3
7 5 1
Thank u for help.

採用された回答

Bruno Luong
Bruno Luong 2022 年 3 月 29 日
A = randi(10,3,6)
A = 3×6
7 7 9 6 6 9 8 2 6 5 9 4 7 5 9 2 4 2
B = A(:,1:2:end)
B = 3×3
7 9 6 8 6 9 7 9 4
C = A(:,2:2:end)
C = 3×3
7 6 9 2 5 4 5 2 2
  1 件のコメント
Berfin Çetinkaya
Berfin Çetinkaya 2022 年 3 月 29 日
Thank u :)

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

その他の回答 (1 件)

Murugan C
Murugan C 2022 年 3 月 29 日
odd_Mat = A(:,1:3:end); % Odd column matrix extraction
even_mat = A(:,2:2:end); % Even column matrix extraction
  1 件のコメント
Berfin Çetinkaya
Berfin Çetinkaya 2022 年 3 月 29 日
Thank u for help :)

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

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by