merge two arrays with different size

3 ビュー (過去 30 日間)
huda nawaf
huda nawaf 2011 年 12 月 29 日
hi, if I have two arrays, each one has different size ex a(1:1000,1:20) b(1:1000,1:30)
I want to merge them to one array as follow c=[a;b]; how I can make them with the same size , merge them thanks

回答 (1 件)

Jan
Jan 2011 年 12 月 29 日
A = rand(10, 20);
B = rand(10, 30);
[sA1, sA2] = size(A);
[sB1, sB2] = size(B);
C(sA1+1:sA1+sB1, 1:sB2) = B;
C(1:sA1, 1:sA2) = A;
This works if B has more or less columns than A.
  1 件のコメント
huda nawaf
huda nawaf 2011 年 12 月 31 日
many thanks

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

カテゴリ

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