1

I tried

myTable.MyField{:}='AAA'

myTable.MyField(:)='AAA'

myTable.MyField{:}={'AAA'}

myTable.MyField{:}=deal('AAA')

but all failed.

Is there any way?

Dims
  • 47,675
  • 117
  • 331
  • 600

1 Answers1

1

MATLAB requires:

To assign to or create a variable in a table, the number of rows must match the height of the table.

So it would be:

myTable.MyField = repmat('AAA', length(myTable.MyField), 1);

or if you know the column number of MyField, you can do:

myTable(:,colnum) = {'AAA'};  %where colnum is the column number

or otherwise if you don't know the column number, you can directly use the column name as well:

myTable(:,'MyField') = {'AAA'};   
Sardar Usama
  • 19,536
  • 9
  • 36
  • 58