How to use Mask parameters in InitFcn

11 visualizaciones (últimos 30 días)
Golden
Golden el 9 de Abr. de 2020
Editada: Golden el 16 de Abr. de 2020
I am using 2017a. I have a need to use a parameter from the mask of a block in the block property's InitFcn function. Is it possible? I have attached the model so you may see what I mean. Thank you.

Respuesta aceptada

Guru Mohanty
Guru Mohanty el 14 de Abr. de 2020
You Can access the block parameters of masked subsystem using get_param and change the block parameter using set_param.
You can make these changes inside InitFcn function.
% To get the Block Parameter
Param= get_param([gcs,'/Subsystem'],'Tend');
% To set Block parameter
set_param([gcs,'/Subsystem'],'Tend','6');
I have attached the modified Simulink Model.
  1 comentario
Golden
Golden el 16 de Abr. de 2020
Editada: Golden el 16 de Abr. de 2020
a followup question: is it possible to make it more generic so I don't have specify the subsystem name in the following command?
Param= get_param([gcs,'/Subsystem'],'Tend');
This way when the block name changes, I don't have to go in and change this line of code. Thanks.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Author Block Masks en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by