0
votes

I have a function in Matlab that requires as the input

column cells, where each cell contains an SPD matrix

To be more precise this function requires 3 input arguments, the first two are column cells, where each cell contains an SPD matrix, But I don't know how to define a column cell in Matlab. I have tried this:

TestData(:,:,12) = T;

TestData is supposed to be my cell column and T is a matrix that should be in this column. for every matrix that I have, I put it in a variable called T and then using above command I add it to a 3D array. So the first matrix is in TestData(:,:,1), The second one is in TestData(:,:,1) and so on. When I run my function with TestData as the input variable i get this error:

Cell contents reference from a non-cell array object.

So I think I didn't define a cell column right.

1
That's not a cell, it's a 3D array like you said. You likely want num2cell(TestData, 3) - Suever

1 Answers

2
votes

A 3D array is not a cell. If you want each 3D slice of your 3D array to be a separate cell element, you could use num2cell followed by a call to squeeze to remove all singleton dimensions and make it an N x 1 cell array.

inputs = squeeze(num2cell(TestData, [1 2]));