how to combine matrices
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Torsten
el 29 de Mzo. de 2023
Editada: Torsten
el 30 de Mzo. de 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 comentarios
Ver también
Categorías
Más información sobre Line Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!