MATLAB Answers

0

Model initialization from a callback in the mask of simulink Block

Asked by Vamsinag Gunti on 21 Aug 2019 at 7:05
Latest activity Answered by Fangjun Jiang on 21 Aug 2019 at 15:36
Hi Everyone,
I am trying to read the compiled sample time of a Block in its mask through a callback connected to a button in the mask of the block. But before I read the Compiled Sampletime, it is necessary for me to initialize the Model, for which I have written the following command in my callback:
set_param(bdroot,'SimulationCommand','Update')
But I get the following error:
2019-08-21_08h59_54.png
I tried another way of executing the same, and yet I am presented with the same error.
evalin('base', 'set_param(bdroot,''SimulationCommand'',''Update'')')
2019-08-20_17h38_17.png
What is it that I am doing wrong?
Thanks in advance :)
Regards,
Vamsi

  6 Comments

Hi,
Thank you for the information. All the parameter values are loaded the moment the Model is loaded. Therefore, if I execute Ctrl+D or execute the following command in my command window, the model does get updated.
set_param(bdroot,'SimulationCommand','Update')
However if I try to update the model through a callback function in the Mask (that I created) of a block I get the error I have attached. Therefore my problem has nothing to do with the Simulink parameters and seems to be something to do with this callback function. What I do not know is, why is the problem being presented only when I try to update the model through a callback function.
From the error message, it looks like that your block is a library link. Can you first try to break the link and test if a callback of model update can be done from a mask? Library link sometimes can make things complicated. Try to put that aside first.
Hi Fangjun Jiang,
My Block is in a library that I use in another Model. I broke the Library Link and the tested it. The Model could be updated from the Mask. So the Problem is the Library Link.
Could you please elaborate on this issue? What has the Library Link to do with this?
Thanks in advance

Sign in to comment.

Products


Release

R2017b

1 Answer

Answer by Fangjun Jiang on 21 Aug 2019 at 15:36

There are a few terms involved here. You need to try it out to see if it is possible to achieve what you desire to do. The point is that you can't self-modify the library block except what is allowed as "Parameterized links"
Dynamic Masked Subsystem
web(fullfile(docroot, 'simulink/ug/create-dynamic-masked-subsystems.html'))
Parameterized Links and Self-Modifiable Linked Subsystems
web(fullfile(docroot, 'simulink/ug/parameterized-links-and-self-modifiable-linked-subsystems.html#bu9117h'))

  0 Comments

Sign in to comment.