set_param 'Table' datatype

6 vues (au cours des 30 derniers jours)
Ubaldo
Ubaldo le 1 Août 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?

Réponse acceptée

Guillaume
Guillaume le 1 Août 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 commentaires
Dhines
Dhines le 15 Déc 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!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programmatic Model Editing dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by