help-octave
[Top][All Lists]
Advanced

[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: Sat, 18 Jan 2014 02:40:19 +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?

The easiest thing is to solve for y and w simultaneously:

% Y(1) = v'= v^2/2 - 2y +2
% Y(2) = y' = v
% Y(3) = w' = y*w +1
% X(1) = v
% X(2) = y
% X(3) = w

function Y=f(X,t); Y=[X(1)*X(1)/2 - 2*X(2) + 2, X(1), X(2)*X(3) + 1]';
endfunction;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]