set_param 'Table' datatype

10 visualizaciones (últimos 30 días)
Ubaldo
Ubaldo el 1 de Ag. de 2016
Comentada: Georgia - Eirini Lazaridou el 23 de Mayo de 2023
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?

Respuesta aceptada

Guillaume
Guillaume el 1 de Ag. de 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 comentarios
Dhines
Dhines el 15 de Dic. de 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
Georgia - Eirini Lazaridou el 23 de Mayo de 2023
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!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Programmatic Model Editing en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by