reuse C code in simulink

4 ビュー (過去 30 日間)
Ruoshi Zhang
Ruoshi Zhang 2015 年 3 月 29 日
回答済み: TAB 2015 年 4 月 6 日
Hello every one,
is is possible that i call a c program from a stateflow chart, then I copy this chart, still in this same model, and execute both with out any conflict?
for example a C program like this
int var; // var is global
int myfunction(int n)
{
var = var + n;
return var;
}
i mean, treat them like two different entities and won't mess up with global variable.
  1 件のコメント
Ruoshi Zhang
Ruoshi Zhang 2015 年 3 月 29 日
btw, also without rename the function in source code, I've got a big program :)

サインインしてコメントする。

回答 (2 件)

Jason Moore
Jason Moore 2015 年 4 月 3 日
Yes, you can create s functions of your legacy C code that can be used in your simulink model. To do this the easiest way is to use the legacy code tool. This tool will allow you to create an s function compile it and create a block that can be used in your model. Here is the link to the documentation.
  1 件のコメント
Ruoshi Zhang
Ruoshi Zhang 2015 年 4 月 3 日
Hello,
I observe that if I use just stateflow block matlab also create s function, do you think they are same?

サインインしてコメントする。


TAB
TAB 2015 年 4 月 6 日
Also you can integrate your C code directly in Stateflow chart for Simulation.
Check "Call Custom C Code Functions" on this page.

カテゴリ

Help Center および File ExchangeComplex Logic についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by