Clear Filters
Clear Filters

Changing S-function block parameters using script

9 views (last 30 days)
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.

Answers (1)

Aiswarya
Aiswarya on 22 Dec 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')

Categories

Find more on Block and Blockset Authoring in Help Center and File Exchange

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!