[catmat]=padconcatenation(a,b,c)
concatenates arrays with different sizes and pads with NaN.
a and b are two arrays (one or two-dimensional) to be concatenated, c must be 1 for
vertical concatenation ([a;b]) and 2 for horizontal concatenation ([a b])
a=rand(3,4)
b=rand(5,2)
a =
0.8423 0.8809 0.7773 0.3531
0.2230 0.9365 0.1575 0.3072
0.4320 0.4889 0.1650 0.9846
b =
0.6506 0.8854
0.8269 0.0527
0.4742 0.3516
0.4826 0.2625
0.6184 0.5161
PADab=padconcatenation(a,b,1)
PADab =
0.8423 0.8809 0.7773 0.3531
0.2230 0.9365 0.1575 0.3072
0.4320 0.4889 0.1650 0.9846
0.6506 0.8854 NaN NaN
0.8269 0.0527 NaN NaN
0.4742 0.3516 NaN NaN
0.4826 0.2625 NaN NaN
0.6184 0.5161 NaN NaN
PADab=padconcatenation(a,b,2)
PADab =
0.8423 0.8809 0.7773 0.3531 0.6506 0.8854
0.2230 0.9365 0.1575 0.3072 0.8269 0.0527
0.4320 0.4889 0.1650 0.9846 0.4742 0.3516
NaN NaN NaN NaN 0.4826 0.2625
NaN NaN NaN NaN 0.6184 0.5161
Andres (2019). Concatenate arrays with different sizes in Matlab (https://www.mathworks.com/matlabcentral/fileexchange/37551-concatenate-arrays-with-different-sizes-in-matlab), MATLAB Central File Exchange. Retrieved .
Create scripts with code, output, and formatted text in a single executable document.
Amy Olivier (view profile)
Corry Corvianawatie (view profile)
hi, it doesnt work for huge matrices.
Error using padconcatenation
Too many input arguments.
Error in mmp_read_ctd (line 18)
ctd =
padconcatenation(C0000000,C0000001,C0000002,C0000003,C0000004,C0000005,...
Stephen Cobeldick (view profile)
@yschefres: see https://www.mathworks.com/matlabcentral/fileexchange/22909-padcat-varargin
Daniela Palma (view profile)
Jacob Vialou-Clark (view profile)
Rafael Gatica (view profile)
yschefres (view profile)
great function! thank you! Any chance to modify it to accept more than two matrices?
Leonardo Ramirez (view profile)