0

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).

aynber
  • 22,380
  • 8
  • 50
  • 63
msmf14
  • 1,449
  • 4
  • 13
  • 19
  • Just to clarify, you're having a hard time setting up custom column and row names of the table? – James Mertz Jun 11 '13 at 14:29
  • Yes. Since I will be pulling column names from a data file, and will be having several tables, I don't want to insert the column names manually – msmf14 Jun 11 '13 at 14:30

1 Answers1

0

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.

James Mertz
  • 8,459
  • 11
  • 60
  • 87
  • Thank you for the answer, KronoS. It should be possible to do that in the GUIDE generated m-file as well? – msmf14 Jun 11 '13 at 14:38
  • 1
    In theory yes, but I've found that GUIDE creation of GUI's is rather a pain. I suggest the use of [GUI Layout Toolbox](http://www.mathworks.com/matlabcentral/fileexchange/27758-gui-layout-toolbox) if you're planning on creating anything remotely complicated. – James Mertz Jun 11 '13 at 14:55
  • That looks great, thanks! And yes MATLAB's GUIDE is terribly confusing. I'll look into GUI Layout Toolbox. – msmf14 Jun 11 '13 at 15:20
  • Just a comment for future users, it was much much simpler to write the GUI code than to use GUIDE. – msmf14 Jun 12 '13 at 18:47