Merge nx3 double matrices present within a 3x1 cell
1 回表示 (過去 30 日間)
古いコメントを表示
I have the following generic code that generates me a 3x1 "output" cell.
a=randi(100,157,2);
b=randi(200,189,2);
c=randi(300,183,2);
mat={a;b;c};
for i=1:size(mat,1)
if i==1
aaa(i)={[mat{i,1} repmat(100,size(mat{i,1},1),1)]};
elseif i==2
aaa(i)={[mat{i,1} repmat(150,size(mat{i,1},1),1)]};
elseif i==3
aaa(i)={[mat{i,1} repmat(200,size(mat{i,1},1),1)]};
end
end
output=aaa';
The internal of "output" is characterized by:
157x3 double
189x3 double
183x3 double
I would like to try to merge all the matrix (nx3), present inside "output", into one array (an example like this: link)
I used the following code but it gives an error due to the fact that the number of rows in each matrix is different.
matrix = [];
for nbr = 1:3
matrix = [matrix, output{nbr,1}];
end
1 件のコメント
採用された回答
C B
2022 年 12 月 11 日
a=randi(100,157,2);
b=randi(200,189,2);
c=randi(300,183,2);
mat={a;b;c};
for i=1:size(mat,1)
if i==1
aaa(i)={[mat{i,1} repmat(100,size(mat{i,1},1),1)]};
elseif i==2
aaa(i)={[mat{i,1} repmat(150,size(mat{i,1},1),1)]};
elseif i==3
aaa(i)={[mat{i,1} repmat(200,size(mat{i,1},1),1)]};
end
end
output=aaa';
matrix = [];
for nbr = 1:3
matrix = [matrix; output{nbr,1}];
end
matrix
0 件のコメント
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!