Filter löschen
Filter löschen

set_param 'Table' datatype

14 Ansichten (letzte 30 Tage)
Ubaldo
Ubaldo am 1 Aug. 2016
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?

Akzeptierte Antwort

Guillaume
Guillaume am 1 Aug. 2016
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.
  4 Kommentare
Dhines
Dhines am 15 Dez. 2022
@Guillaume can you tell set param command for below query
https://in.mathworks.com/matlabcentral/answers/1874647-how-to-access-bus-ports-parameter-from-action-bar-in-buscreator-busselector-blocks
Georgia - Eirini Lazaridou
Mr/Mrs Guillaume i used your example and worked as well. My problem was: at the block Synchronous Machine pu Standard, i wanted to use the command "set_param" in order to change the parameters which are tables.
Thank you for your help!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Programmatic Model Editing finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by