[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lsode twice problem
From: |
Montgomery-Smith, Stephen |
Subject: |
Re: lsode twice problem |
Date: |
Sun, 19 Jan 2014 05:43:54 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 |
On 01/17/2014 02:17 PM, marciopfrs wrote:
> Hello,
>
> I'm using the following commands to solve the ODE:
> % y''(t) = (y'(t))^2/2 - 2y +2
> % y(0) = 1?
> % y'(0) = 0?
> % using the system
> % Y(1) = v'= v^2/2 - 2y +2
> % Y(2) = y' = v
> % X(1) = v
> % X(2) = y
> function Y=f(X,t); Y=[X(1)*X(1)/2 - 2*X(2) + 2, X(1)]'; endfunction;
> X0 = [.7, .845]';
> t = linspace(0, 20, 91);
> X = lsode('f', X0, t);
> % plot(t, X(:,1), t, X(:,2))
> % plot(t, X(:,2))
>
> I tried a lot but was not able to use the solution "y" of this ODE in
> another ODE
> %w'=y*w +1.
>
> How can I do this?
To answer Robert Durkacz's point, here is a different way.
% Wp = w'
% W = w
global pp
pp = spline(t,X(:,2));
function Wp=g(W,t); global pp; Wp = ppval(pp,t)*W(1) + 1; endfunction
W = lsode('g',0,t);
plot(t,W)