help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lsode problems


From: Thomas D. Dean
Subject: Re: lsode problems
Date: Sun, 24 Jul 2016 16:24:54 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0

On 07/24/2016 08:00 AM, CarlB wrote:
I have been messing with lsode for a few days and I just can't get it to
function without errors.
*M-file:*
clear all
clc

% Time span
tspan = [0 1]';

% Initial Conditions
IC = [0 0]';

% ODE Solver
[z,t] = lsode(@odem5,tspan,IC)

*Function*
function zdot = odem5(z,t)


%% if statement for step input f
if t < 0
     f = 0
elseif 0 < t >= .4
     f = 600
else
     f = 0
endif

zdot = zeros(2,1);
zdot(1) = z(2);
zdot(2) = (-12*z(2) - 900*z(1) + .15*f);
endfunction

*This returns the error:*
  LSODE--  REPEATED CALLS WITH ISTATE = 1 AND TOUT = T (=R1)
       In above message,  R1 =  0.0000000000000D+00
  LSODE--  RUN ABORTED.. APPARENT INFINITE LOOP
f = 0
error: lsode: exception encountered in Fortran subroutine dlsode_
error: called from

any help would be great,

Gus



--
View this message in context: 
http://octave.1599824.n4.nabble.com/lsode-problems-tp4678790.html
Sent from the Octave - General mailing list archive at Nabble.com.

_______________________________________________
Help-octave mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-octave

> version
ans = 4.0.2

clear all
function zdot = odem5(z,t)
if t < 0
f = 0;
elseif 0 < t >= .4
f = 600;
else
f = 0;
endif;
zdot = zeros(2,1);
zdot(1) = z(2);
zdot(2) = (-12*z(2) - 900*z(1) + .15*f);
endfunction;

tspan = [0 1]';
IC = [0 0]';
[z,t] = lsode(@odem5,tspan,IC);

> z
z =

0 1
0 1
> t
t = 1

Tom Dean



reply via email to

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