how to merge three matrix into one ?

3 ビュー (過去 30 日間)
Firas Al-Kharabsheh
Firas Al-Kharabsheh 2016 年 4 月 4 日
if i have three matrix with different size like this
A = [ 1 1 0 0 1 0
1 0 1 0 0 1
1 1 0 1 0 1
0 1 0 1 0 0 ]
B = [ 2 1 0
1 1 1
2 1 1
1 1 0 ]
C = [ 0 1 0 0 0 0
3 2 1 2 1 2 ]
And i want to merge them like this ( A is the middle , C above A and B on the Right of A )
D = [ 0 1 0 0 0 0
3 2 1 2 1 2
1 1 0 0 1 0 2 1 0
1 0 1 0 0 1 1 1 1
1 1 0 1 0 1 2 1 1
0 1 0 1 0 0 1 1 0 ]
  4 件のコメント
Firas Al-Kharabsheh
Firas Al-Kharabsheh 2016 年 4 月 4 日
yes its a matrix but i put a spaces between three matrix to explain to you how i want to merge these matrices
Azzi Abdelmalek
Azzi Abdelmalek 2016 年 4 月 4 日
編集済み: Azzi Abdelmalek 2016 年 4 月 4 日
From what you posted, in D, the frist three rows contain 6 elements, and the other rows contain 9 elements. You have to precise if you want to append with zeros or nans. A space is not a number, you can append with empty vectors if D was a cell array

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

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 4 月 4 日
If you want to append with zeros
A = [ 1 1 0 0 1 0
1 0 1 0 0 1
1 1 0 1 0 1
0 1 0 1 0 0 ]
B = [ 2 1 0
1 1 1
2 1 1
1 1 0 ]
C = [ 0 1 0 0 0 0
3 2 1 2 1 2 ]
ma=size(A,2)
mb=size(B,2)
[nc,mc]=size(C)
m=max(mc,mb+ma);
C=[C zeros(nc,m-mc)];
out=[C;A B]
  3 件のコメント
Firas Al-Kharabsheh
Firas Al-Kharabsheh 2016 年 4 月 4 日
thank you
Firas Al-Kharabsheh
Firas Al-Kharabsheh 2016 年 4 月 4 日

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

その他の回答 (0 件)

カテゴリ

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