Changing S-function block parameters using script

15 visualizaciones (últimos 30 días)
vhd
vhd el 27 de En. de 2022
Respondida: Aiswarya el 22 de Dic. de 2023
Hi,
I am using a software called SIMPACK for modeling of a complicated system. I can export an S-Function block from this software to use it in Simulink. I can also define parameters for the model which can be extracted as Subvar parameters in the S-Function.
I can manually open the S-Function block and change the Subvar values and run my model with different parameters. But, I want to do this using scripts in MATLAB. I tried using "set_param('model name/block name', 'Parameter', 'Value'). This script works for different blocks such as sine input block, constant block or gain block, but it does not work for the S-Function block.
When I type the below code for my mode, I receive the below error:
>> set_param('FE_014_SIMPACK_demo_01_linear/FE_014_SIMPACK_demo_01_linear','$_MOUNT_STIFFNESS_X','60')
Simpack Model Export block (mask) does not have a parameter named '$_MOUNT_STIFFNESS_X'
Can you please let me know what I should do and how can i change the subvar parameters using scripts? I have attached the Simulink model I am using here.

Respuestas (1)

Aiswarya
Aiswarya el 22 de Dic. de 2023
Hi vhd,
I understand that you are trying to use a S-Function block in Simulink and modify its parameter values programmatically, instead of changing it in the Mask dialog box. The error you are getting is because you are trying to change the value of the parameter of mask shown as '$_MOUNT_STIFFNESS_X' which is not the actual name of the parameter, but just the prompt text.
To view the actual parameter names of S-function, right-click on the 'FE_014_SIMPACK_demo_01_linear' block and click on Block Parameters. This displays the following:
The parameter that you are trying to modify is 'subvar0'. Similarly if you want to modify '$_MOUNT_STIFFNESS_Y' or '$_MOUNT_STIFFNESS_Z' access subvar1 or subvar2 respectively. Now you can modify the desired parameter as follows:
set_param('FE_014_SIMPACK_demo_01_linear/FE_014_SIMPACK_demo_01_linear','subvar0','60')

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by