Get extra outputs from a function called via odesolver

3 ビュー (過去 30 日間)
Jose
Jose 2012 年 4 月 1 日
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 Center および File ExchangeOrdinary Differential Equations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by