2
votes

I have a virtual subsystem with a bunch of parameters. I would like to use those parameters to calculate other properties of the block. This needs to be done before the simulation starts, but after the block has been initialized.

I created a script that would do the calculations, and tried to get it to run from the StartFcn block callback. But the script cannot access the parameters (which are input by the user through the mask) in the callback. I'm guessing this is because those parameters aren't available in the Matlab workspace, only within the block.

Is there any way to access those parameters through StartFcn? Failing that, is there another way, instead of the StartFcn, through which I can perform some calculations BEFORE simulation starts?

To clarify, I cannot use the Initialization tab in the block's mask because the script requires data from other blocks too (which are available in the workspace at the start of the simulation).

1

1 Answers

1
votes

Your guess is correct, block callbacks are evaluated in the base workspace, but mask parameters are part of the mask's private workspace. To access them use get_param and gcb within your callback function.

value = get_param(gcb, 'my_param_name');