I am trying to create a uitable in matlab. Consider the following simple example:
f = figure;
data = rand(3);
colnames = {'X-Data', 'Y-Data', 'Z-Data'};
t = uitable(f, 'Data', data, 'ColumnName', colnames, ...
'Position', [20 20 260 100]);
Next, I am trying toset the width and height of the uitable to match the size of the enclosing rectangle:
t.Position(3) = t.Extent(3);
t.Position(4) = t.Extent(4);
However I get the following error:
>> t.Position(3) = t.Extent(3);
t.Position(4) = t.Extent(4);
Attempt to reference field of non-structure array.
When I try to view what t
is, I get:
>> t
t =
2.1030e+03
I don't know what this result means! I am a little confused as this is the first time I am working with uitable
and I am very new to MATLAB too.