I am using GUIDE to build my first GUI interface in MATLAB.
I have several matrices I want to display using the uitable
. For now let's focus on one matrix, say myMatrix [10x5]
Now I have two cells of strings, columnNames (1x5)
, and another, rowNames (10x1)
. I would like to set these cells to the row and column names of the table, but I cant yet figure out how to do this.
The MATLAB help page says you can use a cell of strings to do this, however in the property inspector, and under ColumnName, the only non-numeric option is to enter the names manually.
Any help would be appreciated (or suggestions to go about this in a different way).
In order to have custom Row/Column Names you have to pass a cell of strings (using {<names>}
) into the ColumnName
and RowName
properties of the uitable
. Here is an example directly from MatLab's uitable
documentation:
f = figure('Position',[200 200 400 150]);
dat = rand(3);
cnames = {'X-Data','Y-Data','Z-Data'}; % These are your column names
rnames = {'First','Second','Third'}; % These are your row names
t = uitable('Parent',f,'Data',dat,'ColumnName',cnames,...
'RowName',rnames,'Position',[20 20 360 100]);
When parsing you're file, be sure to create the lists as a cell of strings.