S-function Builder - Run Only Once

3 次查看(过去 30 天)
I am working with a simulink model in 2013b, where I need the S-function builder to call a function in a dll once. This function is an initialize statement, is there a way I can run all the other commands in the dll at each time step while running the initialize statement just once? I did not make the dll by the way, it is a black box to me other than the C method inputs and outputs.
dll:
%
extern void params(const alpha[]);
extern void init_Func(void);
extern void inputs(const double inp[]);
extern void outputs(double Out1[], double Out2[]);
I would like the init_Func and params to be run only at the start of the simulation. alpha in params is a parameter that is defined in the s-funciton builder.
  1 个评论
Jim Riggs
Jim Riggs 2018-8-7
There is probably a way to do what you want, but you will need to give some more information about how to use the dll. What is the interface, inputs and return value, etc.

请先登录,再进行评论。

采纳的回答

Jim Riggs
Jim Riggs 2018-8-7
Here is a technique that I sometimes use. You can input an integer or Boolean parameter to the S-function. Use a "Memory" block with the initial condition set to '1' or "True", and feed the memory block with a constant "0" or "False". The memory block will supply the initial condition of "True" on the first pass only, and all subsequent passes the value will be "False". This provides the S-function a signal that you can use to select the initialization function.

更多回答(0 个)

产品


版本

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by