Get extra outputs from a function called via odesolver

3 vues (au cours des 30 derniers jours)
Jose
Jose le 1 Avr 2012
Hello
I'm modelling a system of differential algebraic equations, I make a file to use/call the ode solver on the model inside fun(t,y)
function [t,y,...]=callDAE
[t1,y1]=ode15s(@(t,y) fun(t,y),tspan,y0,options);
.
.
.
end
(In options I define the DAE mass matrix)
Inside fun(t,y) I calculate a lot of variables.
Using the outputs for [t1,y1], It's posible to calculate again the same variables in callDAE, but that mean to write again a lot of functions, and some other problems. So I wan't to know if is possible to get the variables calculated inside fun(t,y) to use them on callDAE?
Just as an example, the next code is something like I want, but the odesolvers can't be used that way:
function [t,y,...]=callDAE
[t1,y1,Kp,Lq,Rz,Mw,...]=ode15s(@(t,y) fun(t,y),tspan,y0,options);
.
.
.
end
The syntaxis on the example is not possible, according to the odesolver. The syntaxis is like on the documentation [T,Y,TE,YE,IE] = solver(odefun,tspan,y0,options), but that give 'events' relationed variables, im not interested on them.
Please tell if im not clear enough. Thanks
  2 commentaires
Jose
Jose le 1 Avr 2012
Another question I have, is there a way to create a variable on the Workspace outside of the function with a command inside the function?
Walter Roberson
Walter Roberson le 2 Avr 2012
assignin() -- but keep in mind that your function might be called at an arbitrary depth by ode15s.

Connectez-vous pour commenter.

Réponses (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by