How to put different arrays in one big array?
2 ビュー (過去 30 日間)
古いコメントを表示
Dear all,
I have three arrays with different lenght
A = [1,2,3,4,5,6,7,8,9,10];
AA = A';
B = [10,20,30,40,50,60,70,80,90];
BB = B';
C = [10,20,30,40,50,60,70,80,90,100,110];
CC = C';
I want to put them all in one big array next to each other, so they appear like this
All =
1 10 10
2 20 20
3 30 30
4 40 40
5 50 50
6 60 60
7 70 70
8 80 80
9 90 90
10 100
110
Because of size difference I couldn't use this
All(:,1) = AA;
All(:,2) = BB;
All(:,3) = CC;
Any idea how to do solve it?
Thank you,
Meshoo
0 件のコメント
回答 (2 件)
Honglei Chen
2017 年 1 月 31 日
You need to either pad them into same size or you can use cell array
AllArray = {AA, BB, CC}
HTH
Andrei Bobrov
2017 年 2 月 2 日
D = {A,B,C};
s = cellfun(@numel,D);
m = max(s);
n = numel(D);
out = zeros(m,n);
for ii = 1:n
out(1:s(ii),ii) = D{ii};
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!