Implementing a Discrete Integrator in a Function
Show older comments
I am currently using a discrete integrator block in Simulink. It is part of a PLL, so I need it to integrate up to 2*pi then reset to zero and repeat, exactly as it does in the included Simulink 3-ph PLL block.
I would now like to implement this integrator as a MATLAB function as a prelude to implementing it in C code. However, I have run into a problem as I need to use persistent variables to store the state, however, Simulink does not allow persistent variables within an algebraic loop. Instead of using persistent variables, I tried to use variables stored in the MATLAB workspace and pass them as parameters, however, MATLAB passes them by value so the original variables remain unaltered after each iteration.
Has anyone tackled this issue before?
Answers (1)
Euan Andrew
on 7 Sep 2020
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!