putting several matrices as one

i have got one matrix with 2 columns and another with 5. i want to put them togehter as one matrix with 7 columns. overall the rows are similar in all of them

 採用された回答

per isakson
per isakson 2017 年 10 月 10 日
編集済み: per isakson 2017 年 10 月 10 日

1 投票

The matrices must have the same number of rows and have values of the same class.
len = 7;
A1 = ones( len, 2 );
A2 = 2*ones( len, 5 );
M = cat( 2, A1, A2 ); % or shorter [A1,A2]
whos M
returns
Name Size Bytes Class Attributes
M 7x7 392 double

その他の回答 (1 件)

Cedric
Cedric 2017 年 10 月 10 日

2 投票

A = randi( 10, 3, 2 )
B = randi( 10, 3, 5 )
C = [A, B]

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

質問済み:

AA
2017 年 10 月 10 日

編集済み:

2017 年 10 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by