how to combine matrices
1 回表示 (過去 30 日間)
古いコメントを表示
I have 4 matrix xp1,...xp4 and I want to combine them into one(xp):
I'm getting this error from the last line of script
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
any one can help please?
% xp1 is a 13874X101 matrix
% xp2 is a 13836X88 matrix
% xp3 is a 14439X87 matrix
% xp4 is a 15351X117 matrix
szx1 = max([size(xp1,1),size(xp2,1),size(xp3,1),size(xp4,1)]);
szx2 = sum([size(xp1,2),size(xp2,2),size(xp3,2),size(xp4,2)]);
xp = nan(szx1,szx2);
xp=[xp1 xp2 xp3 xp4];
0 件のコメント
回答 (1 件)
Torsten
2023 年 3 月 29 日
編集済み: Torsten
2023 年 3 月 30 日
I think you mean
xp1 = rand(2,3);
xp2 = rand(4,5);
xp3 = rand(1,4);
xp4 = rand(12,18);
szx1 = max([size(xp1,1),size(xp2,1),size(xp3,1),size(xp4,1)]);
xp1 = [xp1;nan(szx1-size(xp1,1),size(xp1,2))];
xp2 = [xp2;nan(szx1-size(xp2,1),size(xp2,2))];
xp3 = [xp3;nan(szx1-size(xp3,1),size(xp3,2))];
xp4 = [xp4;nan(szx1-size(xp4,1),size(xp4,2))];
xp = [xp1,xp2,xp3,xp4]
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!