Asked by Meg Carr
on 8 Mar 2019

I have a 3D cell array 'A' of size 120 x 180 x 365 (latitude, longitude, day of year).

If I call up a single cell (e.g. A(1,1,1)), this opens matrix 'B' which has two columns (vessel identity, speed), but the number of rows varies by cell. Some cells do not contain any data and display [ ] instead of a B matrix.

I need to make one B matrix that displays all the vessel identities and speeds for A(1,1,1:365)

How can I vertically concatenate matrix B in the third dimension?

Thank you for your help.

Answer by Jos (10584)
on 8 Mar 2019

B = cat(1,A{1,1,1,:}) % N-by-2 array

Meg Carr
on 12 Mar 2019

I just verified, and A{1,1,1} results in a 1 x 18 cell array.

B = cat(1,A{1,1,1,:}), suggested by Jos, results in the same 1 x 18 cell array.

cat(1,A{1,1,:}) results in this error:

Error using cat

Dimensions of matrices being concatenated are not consistent.

Walter Roberson
on 13 Mar 2019

Walter Roberson
on 13 Mar 2019

temp = A{1,1,1};

B = vertcat(temp{:});

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 0 Comments

Sign in to comment.