ODE function will not call the OutputFcn
Afficher commentaires plus anciens
I want to access specific variables which have been solved for in the ODE function but are not differential equations. I am setting an 'OutputFcn', however it is not being accessed while the program is being run. Here are the important parts of my code:
options = odeset('OutputFcn',@(status)RotorOut(t,y,flag));
[t,y] = ode45(@QR_solver,delt,y0,options,[],D);
---
function dydt = QR_solver(t,y,D)
...
rs = XX;
...
end
---
function status = RotorOut(t,y,flag)
global rs k
if flag ~= strcmp(flag,'init')|strcmp(flag,'done')
rotspeed = evalin('base','rotspeed');
k = k + 1;
rotspeed(k) = rs;
assignin('base','rotspeed',rotspeed)
status = 0;
end
t % just to verify the function is being called
end
Am I calling the function wrong? Is there a better to access the variable rs?
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!