S-function Builder - Run Only Once

7 ビュー (過去 30 日間)
Ganesh Ramkumar
Ganesh Ramkumar 2018 年 8 月 7 日
回答済み: Jim Riggs 2018 年 8 月 7 日
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 件)

カテゴリ

Help Center および File ExchangeBlock and Blockset Authoring についてさらに検索

製品


リリース

R2013b

Community Treasure Hunt

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

Start Hunting!

Translated by