Error in ode45 (line 107)
Mostrar comentarios más antiguos
Hello, I'm trying to model the biomass accumulation over time of a microorganism that depends on temperature using a differential equation that I want to solve with ode45 function. But I got this error message:
Error using odearguments
@(TIME,XI)DXDT(TIME,XI,TEMP,PARAM,PARAM_PH,PH) returns a vector of length 29613, but the length of initial conditions vector is 1. The vector returned by
@(TIME,XI)DXDT(TIME,XI,TEMP,PARAM,PARAM_PH,PH) and the initial conditions vector must have the same number of elements.
Error in ode45 (line 107)
odearguments(odeIsFuncHandle,odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
After checking, I figured out that the ode45 function doesn't take my temperature vector but only one cell of it (knowing that the size of my temperature and time vectors is the same).
Can you help me out to solve this issue please?
Here is my code for ode45:
tspan = Time; %Time vector with the same length as experimental data
%C0 is the initial biomass concentration
%the vector param contains my parameters [tmin,topt,tmax,mumax]
[t,xi] = ode45(@(t,xi) dxdt(t,xi,temperature,param),tspan,C0, odeset('RelTol',1E-3));
Here is my dfunction to calculate the ifferential equation:
function dC=dxdt(t,C,Temp,param,param_ph,pH)
dC=C.*phi(param,Temp);
end
Thanks in advance for you help :)
3 comentarios
Cris LaPierre
el 15 de Mayo de 2024
Editada: Cris LaPierre
el 15 de Mayo de 2024
Your ode function must return the result for a single time step. The error is saying your function is returning too many outputs. The outputs should be a column vector the same length as your initial conditions.
Your odefxn expects the following inputs
- Current time, t
- Previous timestep output, C (this is the value of dC in the previous time step)
- Additional input, Temp (undefined)
- Additional input, param (undefined)
- Additional input, param_ph (undefined)
- Additional input, pH (undefined)
We don't really have enough information to answer your question yet (what is phi?). Could you share a working example that throws the error message?
Yob
el 16 de Mayo de 2024
Yob
el 16 de Mayo de 2024
Respuestas (0)
Categorías
Más información sobre Ordinary Differential Equations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!