how to combine matrices
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Torsten
am 29 Mär. 2023
Bearbeitet: Torsten
am 30 Mär. 2023
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 Kommentare
Siehe auch
Kategorien
Mehr zu Line Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!