[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lsode problems
From: |
Tatsuro MATSUOKA |
Subject: |
Re: lsode problems |
Date: |
Mon, 25 Jul 2016 08:40:06 +0900 (JST) |
> From: CarlB
> To: help-octave
> Cc:
> Date: 2016/7/25, Mon 00:00
> Subject: lsode problems
>
> 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
>
From manual
if (condition)
then-body
elseif (condition)
elseif-body
else
else-body
endif
if startements require ().
What is this? Apparently odd
0 < t >= .4
You would like to mean
( (0<t) & (t<=.4) )
right ? (& is required.) )
Perhaps the below is correct for if block
if (t < 0)
f = 0;
elseif ((0 < t) & (t <= .4))
f = 600;
else
f = 0;
endif
Tatsuro