Question

I've been having a lot of trouble getting simulink's block callbacks to run, and the documentation is woefully inadequate and disorganized. It seems that I'm misunderstanding multiple points of how Simulink compiles models, but since StackOverflow dislikes multi-part questions, I will post them one at a time.

The situation: I have a library of components, each of which is a virtual subsystem whose parameters are defined through the masks. Block A has Parameter a which is sent to the base workspace using the 'assignin' command.

Next, the block B has a parameter b which is initialized in the Initialization tab of the mask.

Finally, the StartFcn callback of the block B runs a script which needs to reference both a and b to calculate c. In the script, I reference a simply as a because it's in the 'base' workspace, and I reference b using get_param(gcb,'b').

Now, this last command works when the parameter b is a user input (so it's a constant value). But in my case, this b is calculated using other parameters in the Initialization tab. And for some reason, in the script, this parameter is always zero.

I added a display within the block B to see what these values are, and they are clearly non-zero.

Can someone please explain why the script cannot seem to get the real value of the areas out of the block?

Was it helpful?

Solution

You can get the masked workspace variable using getworkspacevariable

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top