MATLAB: Set_param ‘Table’ datatype

lookup tableMATLABn-d lookup tableset_paramsimulinktable

Hi all. I cannot set the 'Table" by using set_param
my_data = [1 1 1 1];
set_param(char(my_table),'Table',my_data)
Invalid setting in Lookup_n-D block 'table_xyz' for parameter 'Table'
my_data = [1 1 1 1];
set_param(char(my_table),'Table',num2str(my_data))
Parameter 'Table' setting: "1 1 1 1" cannot be evaluated.
Caused by:
Error: Unexpected MATLAB expression.
my_data = [1 1 1 1];
set_param(char(my_table),'Table',{my_data})
Invalid setting in Lookup_n-D block 'table_xyz' for parameter 'Table'
On the other hand, by using numerical value, e.g.
my_data = [1 1 1 1];
set_param(char(my_table),'Table','[1 1 1 1]')
It works. any thoughts?

Best Answer

Assuming mydata is a row vector, this should work:
assert(isrow(mydata), 'data is not row vector');
set_param(char(my_table), 'Table', ['[', num2str(mydata), ']']);
Note that depending on the values in mydata you may need to tweak the format string of num2str to get an accurate representation of the numbers as text.