How to call a function within an other function in simulink with the S-Function-Builder, having static variables
显示 更早的评论
Hello, i am trying to convert c-code to simulink models. Now i have a problem, which i couldn't solve yet. Hope you can help me. I have the following problem: thera are for example three functions in C; f1.c, f2.c and counter.c.
int counter (void) { static int count; count=count+1; return count; } (<=Block1)
int f1(int a) {int c=counter(); int b=c+a; return b; } (<=Block2)
int f2(int a) {int c=counter(); int d=c-a; return d; } (<=Block3)
I am able to generate blocks from this code, my only problem is, how can I get the variable count stay static in Simulink? The generated blocks dont have the same value for count in the simulation. Although there is only one source code in C for counter. Thank you in advance!!!
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Simulink Coder 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!