Get extra outputs from a function called via odesolver

1 次查看(过去 30 天)
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 个评论
Jose
Jose 2012-4-1
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 2012-4-2
assignin() -- but keep in mind that your function might be called at an arbitrary depth by ode15s.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by