How to call a function within an other function in simulink with the S-Function-Builder, having static variables
Mostrar comentarios más antiguos
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!!!
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Simulink Coder en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!