4

I am working with MATLAB GUI. I have a push button, when I press it, it is going to be like this:

uitable result

To show that table, I wrote this script:

t=uitable;
set(t,'Data',y)

y is the variable to show the numbers in the table.

The problem is, I want to change the column names. For example, the first column is going to be named X, the second column is Y, the third column is Z, the fourth column is T. What script should I add to change the name of the column?

Robert Seifert
  • 25,078
  • 11
  • 68
  • 113
Alvi Syahrin
  • 373
  • 3
  • 7
  • 16

2 Answers2

6

You can change the column names using set

set(t, 'columnname', {'X', 'Y', 'Z', 'T'});
H.Muster
  • 9,297
  • 1
  • 35
  • 46
  • So, there will be two lines of `set`? The first is yours, and the next line is mine. Am I right? – Alvi Syahrin May 27 '13 at 09:56
  • Yes, that will work, but, if preferred, you can also pack both lines in one: `set(t,'Data', y, 'columnname', {'X', 'Y', 'Z', 'T'});` – H.Muster May 27 '13 at 09:58
2

The correct way is this one:

app.UITable.ColumnName = {'X', 'Y', 'Z', 'T'};
Cris Luengo
  • 55,762
  • 10
  • 62
  • 120
  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 27 '23 at 11:58