S-function Builder - Run Only Once
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commento
Jim Riggs
il 7 Ago 2018
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.
Risposta accettata
Jim Riggs
il 7 Ago 2018
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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Block and Blockset Authoring in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!