0

我正在使用 ODE 模型,我必须将向量放入变量中然后求解它,但我有一些参数取决于模型的某些方程,例如辅助函数/方程,但我得到了这个错误:

Error using Hovorka2004_Prueba>fun
Too many output arguments.

Error in odearguments (line 88)
f0 = feval(ode,t0,y0,args{:});   %
ODE15I sets args{1} to yp0.

Error in ode45 (line 114)
[neq, tspan, ntspan, next, t0,
tfinal, tdir, y0, f0, odeArgs,
odeFcn, ...

Error in Hovorka2004_Prueba (line 8)
[t,x]=ode45(@fun,tspan,x0);

这是我到目前为止所拥有的:

function [t,x]=Hovorka2004_Prueba
    tspan=[0;100];
    x0 = [0.1249; 0.0941; 0; 0;0; 0.7665;0.9519; 0.8473];
    global out1
    [t,x]=ode45(@fun,tspan,x0);
    out1=[t,x]
     assignin('base','out1',out1);
     figure
        subplot(2,1,1)
        plot(t,x(:,1));
        subplot(2,1,2)
        plot(t,x(:,5));
    end
    function fun(t,x)
    uu1 = importdata('datossinmodi.mat'); 
    ufun = @(t) interp1(1:length(uu1), uu1, t, 'nearest', 0); 
% Begining of the parameters
      % Constants:
        F01= 0.0097; 
    EGP0= 0.0161;
    k12=0.066;
    DG=0;
    AG=0.8;
    tmaxG=40;
    VG= 0.16;
    tmaxI=55;
    Ke=0.138;
    VI=0.12;
    Ka1=0.006;
    Ka2=0.06;
    Ka3=0.03;
    Kb1= 51.2e-4*Ka1; 
    Kb2= 8.2e-4*Ka2;  
    Kb3= 520e-4*Ka3;  
    % Auxiliar Functions/Equations:
     G=x(1)/VG;
    if G>=4.5
        F01_C=F01;
    else
        F01_C=F01*G/4.5;
    end
    if G>=9
        FR=0.003*(G-9)*VG;
    else
        FR=0;
    end
     UI=x(4)/tmaxI;
     UG=(DG*AG*t*exp(-t/tmaxG))/(tmaxG)^2;
% Model:
  f = @(t,x) [   
          -((F01_C/VG*G)*x(1))+ x(6)*x(1) + k12*x(2) - FR + UG + EGP0*(1-x(8));  %(1)  
          x(6)*x(1)-(k12+x(7))*x(2);             %(2)
          ufun(t)-(x(3)/tmaxI);                  %(3) IN HERE ufun(t) IS WHERE I AM TRYING TO PUT THE VECTOR
          (x(3)/tmaxI)-(x(4)/tmaxI);             %(4)
           UI/VI - Ke*x(5);                      %(5)
          -Ka1*x(6)+ Kb1*x(5);                   %(6)
          -Ka2*x(7)+ Kb2*x(5);                   %(7)
          -Ka3*x(8)+ Kb3*x(5);                   %(8)
          ];
  end 

我怎样才能让它工作?它出什么问题了?

非常感谢你的帮助 (:

编辑:我试过function dx=fun (t,x)但它一直发送错误:

>> Hovorka2004_Prueba
Error in Hovorka2004_Prueba>fun (line 21)
uu1 = importdata('datossinmodi.mat');

Error using feval
Output argument "dx" (and maybe
others) not assigned during call to
"C:\Users\AnnieA\Dropbox\Tesis (A.
Olay)\MATLAB Simulations\Lectura de
Vectores\Hovorka2004_Prueba.m>fun".

Error in odearguments (line 88)
f0 = feval(ode,t0,y0,args{:});   %
ODE15I sets args{1} to yp0.

Error in ode45 (line 114)
[neq, tspan, ntspan, next, t0,
tfinal, tdir, y0, f0, odeArgs,
odeFcn, ...

Error in Hovorka2004_Prueba (line 8)
[t,x]=ode45(@fun,tspan,x0);

也有,function f=fun(t,x)但它发送这个

>> Hovorka2004_Prueba
Error using odearguments (line 93)
FUN returns a vector of length 1,
but the length of initial conditions
vector is 8. The vector returned by
FUN and the initial conditions
vector must have the same number of
elements.

Error in ode45 (line 114)
[neq, tspan, ntspan, next, t0,
tfinal, tdir, y0, f0, odeArgs,
odeFcn, ...

Error in Hovorka2004_Prueba (line 8)
[t,x]=ode45(@fun,tspan,x0);
4

0 回答 0