Reputation: 173
I have two multi-dimensional arrays:
% Dimensions not matrix multiplication
array1 = a*b*c*d
array2 = a*b*c*e
and I want to concatenate the array as:
a*b*c*(d+e).
Is this possible in MATLAB without loop?
I've tried the following and it doesn't work:
array3 = [array1;array2] % does not work
Upvotes: 2
Views: 1125
Reputation: 30047
You want to use Matlab's cat
function, concatenating in the 4th dimension as follows:
array3 = cat(4, array1, array2)
Note from the above linked docs, that what you have tried is concatenation in the 1st dimension,
"cat(1, A, B)
is the same as [A; B]
."
Upvotes: 4