Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: ode45 solver and outputfcn
Replies: 2   Last Post: Apr 26, 2011 2:12 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Red Star

Posts: 135
Registered: 6/28/08
ode45 solver and outputfcn
Posted: Apr 25, 2011 5:19 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I often solved my ODEs by the sintax:

[T,Y] = ode15s(@vdp1000,[0 3000],[2 0]);

and let's say the problem was:

function dy = vdp1000(t,y)
dy = zeros(2,1); % a column vector
dy(1) = y(2);
dy(2) = 1000*(1 - y(1)^2)*y(2) - y(1);

it works fine.

Now let's suppose my ODEs is

function dy = vdp1000(t,y)
dy = zeros(2,1); % a column vector
% K the new value
K = newvalue(t,y)
dy(1) = y(2);
dy(2) = 1000*(1 - y(1)^2)*y(2) - y(1) + K;

It means there is a K value computed at each time by a function called
newvalue.
I would have this value T in output at each output time. For example:
[T,Y, K] = ode15s(@vdp1000,[0 3000],[2 0]);

Untill now, at the end of my simulation, I "rebuild" T, but it is a
time consuming procedure and dumb.
I mean that:
[T,Y] = ode15s(@vdp1000,[0 3000],[2 0]);
for i=1:length(T)
K(i) = newvalue(T(i), Y(i,:) )
end

I suspect the option 'outputfcn ' could help me.
Someone knows a better method?



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.