I wrote some function, that makes use of persistent variables, for example:
function y = integrator(x, t)
persistent yr; %result
...
and then, if I call it only once in a cycle, everything works fine:
x = integrator(x_dot, t);
but if I want to call it twice with different arguments, it will give wrong results:
x = integrator(x_dot, t);
y = integrator(y_dot, t);
This is not unexpected, but how can I deal with that? Use something different (non-persistent) variables or what?
I'm used to deal mostly with Simulink and the solution is not obvious to me.