简体   繁体   中英

Why do i receive an 'x' undefined error with ode23s but not with ode23 or ode15s in OCTAVE?

I'm trying to solve some ODEs in OCTAVE with solver ode23s (the exact same algorithm is running perfectly in Matlab) but i'm receiving an 'x' undefined error, while that doesn't happen when i'm using the solvers ode23 or ode15s even though that's the only change i'm making.

Below you can see the mentioned code and the error:

    model = [Fg1 Fg2 ui mi ... gi]; %model is a vector of (1,77) 
    options = odeset('RelTol',1e-4,'AbsTol',5e-6*ones(16,1));
    [T,Y] = ode23s(@odesys_test,0:dt:10,init,options,model);

The function code:

function [dx] = odesys_test(t,x,model)

global tt

Fg1 = model(1);

The error:

error: 'model' undefined near line 5, column 5

error: called from odesys_test at line 5 column 5 runge_kutta_23s at line 121 column 5 integrate_adaptive at line 135 column 39 ode23s at line 217 column 12 DOF2_test at line 189 column 15

According to octave's documentation, the syntax is

[T, Y] = ode23s (FUN, TRANGE, INIT, ODE_OPT)

You are passing an extra model parameter which is not part of the function's signature.

Also the odesys_test function you created does not fulfill the specification expected by ode23s . Read the documentation carefully.

Perhaps what you mean to do is simply create an anonymous function which does fulfill the specification, and use that to 'wrap' around your odesys_test function, eg

[T,Y] = ode23s( @(t, x) odesys_test(t, x, model), 0:dt:10, init, options,model );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM