MATLAB: Values within a cell array must be numeric, logical, or char

guiuitable

Don't seem to know what's wrong. I've tried everything I know. Here's the snippet containing the code:
Fg = varargin{1};
Ug = varargin{2};
eps = varargin{3};
sig = varargin{4};
elems = varargin{5};
L = varargin{6};
A = varargin{7};
E = varargin{8};
PPM={};
for i=1:3
out1=num2cell(i);
out2={num2cell(elems(1,1)) num2cell(elems(1,2))};
out3=num2cell(L(i,1));
out4=num2cell(A(i,1));
out5=num2cell(E(i,1));
PPM{i}={out1 out2 out3 out4 out5};
end
out={PPM}
set(handles.uitable1,'Data',out);
% Choose default command line output for postprocess
handles.output = hObject;

Best Answer

Looking backwards,
out={PPM}
so out is a 1 x 1 cell array whose first and only element is the array PPM
PPM{i}={out1 out2 out3 out4 out5}
so PPM is a 1 x 3 cell array, and each cell in PPM is to contain a 1 x 5 cell array
out1=num2cell(i);
out2={num2cell(elems(1,1)) num2cell(elems(1,2))};
out3=num2cell(L(i,1));
out4=num2cell(A(i,1));
out5=num2cell(E(i,1));
the first, third, fourth, and fifth of which are to be cell arrays containing scalars, and the second of which is to be a 1 x 2 cell array inside of each of which is a cell array containing a scalar
If I analyze correctly, out is
{{{{scalar} {{scalar} {scalar}} {scalar} {scalar} {scalar}} {{{scalar} {{scalar} {scalar}} {scalar} {scalar} {scalar}} {{{scalar} {{scalar} {scalar}} {scalar} {scalar} {scalar}}}}
This is not something that can be represented in a uitable.
The data property for a uitable can be:
  • a numeric array
  • a logical array
  • a character vector
  • a cell array, each entry of which is a numeric scalar, a logical scalar, or a character vector
It is never possible to for the data property to have a cell inside a cell.
You have a particular problem with out2: in uitable, it is not possible for a single column to store multiple values (except in that character vectors are, in one sense, multiple values).
I think you need to go for 6 columns.
It looks to me as if you could construct a simple numeric output.
I notice that your out2 does not subscript with i. In the below I presume that was a mistake, that you want different outputs for the out2
idx = 1 : 3;
PPM = [idx.', elems(idx,1:2), L(idx,1), A(idx,1), E(idx,1)];
set(handles.uitable1,'Data', PPM);
This code replaces all of the looping and all of the {} construction. All of your data appears to be numeric so there is no need to break it up into individual cells. (I cannot actually tell that for sure, though: it is not impossible that some of your data is character vector)