How to solve this?
Mostra commenti meno recenti
function modelo_cascada
X0 = input(" X0 value : ")
P0 = input(" P0 value : ")
umax = input("miumax value: ")
xmax = input("xmax value: ")
d1 = input("value dil1: ")
%d2 = input("value dil2: ")
tstep= input("value t step: ")
t=linspace(0,22200);
ts=t*tstep
[Tiempo,Conc]=ode23s(@fder,[ts],[X0 P0])
%Fermentación primaria
function dC=fder(t,C)
X=C(1,1)
P=C(2,1)
u=(umax)*((xmax-X)/xmax)
dC(1,1)=u %dX/dt
dC(:,:)=X+(u*X*ts)-(d1*X*ts)
end
Cf = Conc(end, :)
end
Unable to perform assignment because the size of the left side is 1-by-1 and the
size of the right side is 1-by-100.
Error in modelo/fder (line 23)
dC(2,1)=X+(u*X*ts)-(d1*X*ts)
Error in odearguments (line 92)
f0 = ode(t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ode23s (line 122)
= odearguments(odeIsFuncHandle, odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
Error in modelo (line 12)
[Tiempo,Conc]=ode23s(@fder,[ts],[X0 P0])
Risposte (1)
Walter Roberson
il 13 Nov 2022
t=linspace(0,22200);
ts=t*tstep
t is a vector and tstep is scalar (we assume) so ts will be a vector.
dC(:,:)=X+(u*X*ts)-(d1*X*ts)
ts is a vector so the right hand side is a vector.
You initialized
dC(1,1)=u
which creates dC as a scalar. So in the assignment to dC(:,:) the left side only has enough room for a scalar.
ts=t*tstep
[Tiempo,Conc]=ode23s(@fder,[ts],[X0 P0])
so at that level, in the driver script, t refers to... I'm not sure, really. t does not directly control how many steps are being made: that is according to the default size used for linspace(), which is 100. In any case, t in the calling script is not being used as time. Since it is ts that is being passed to ode23s(), ts is being used as time in the driver script.
function dC=fder(t,C)
and the function receives any given ts value under the name t
dC(:,:)=X+(u*X*ts)-(d1*X*ts)
but the code never uses the input t and instead uses the complete time vector, ts
I do not understand that linspace(), but you confuse readers and yourself when you use t for two different purpose.
Categorie
Scopri di più su Ordinary Differential Equations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!