Error ode must return column vector

14 vues (au cours des 30 derniers jours)
jimmy lei
jimmy lei le 19 Oct 2017
function diffeq = ode(w, v)
k1 = 0.5*exp(2-640/v(4));
Kc = 10*exp(2064/v(4)-7.2);
k3 = 0.005*exp(4.6-2116/v(4));
Ta = 500;
Ua_rho = 16;
Cpa =100;
Cpb =100;
Cpc =100;
deltaH1=-1800;
FC = v(1)*Cpa +v(2)*Cpb + v(3)*Cpc;
diffeq(1)=k1*v(2)-k1/Kc*v(1);
diffeq(2)=k1/Kc*v(1)-v(2)*(k1+k3);
diffeq(3)=k3*v(2);
diffeq(4)=((k1/Kc*v(1)-v(2)*(k1+k3))*deltaH1 - Ua_rho*(v(4)-Ta))/FC;
====
wspan = [0 100];
IC(1)=1; IC(2)=1; IC(3)=0; IC(4)=330;
[w,vv] = ode15s(@ode,wspan,IC);
Fa = vv(:,1); Fb = vv(:,2); Fc = vv(:,3); T = vv(:,4);
plot(w,Fa, w,Fb, w,Fc, w,T)
xlabel('weight of catalyst')
ylabel('Flow Rates and Temp')
Error using odearguments (line 93)
ODE must return a column vector.
Error in ode15s (line 150)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in odesolve (line 5)
[w,vv] = ode15s(@ode,wspan,IC);
It says my ode needs to return a column, but my ode if im not mistaken is a 4by4 matrix so I don't understand how is it no a column vector?

Réponse acceptée

Torsten
Torsten le 19 Oct 2017
Add the line
diffeq = zeros(4,1);
at the beginning of your function "ode".
Best wishes
Torsten.

Plus de réponses (1)

Walter Roberson
Walter Roberson le 19 Oct 2017
A column vector has to be something-by-1 . A 4 x 4 is not a vector. You need to return 16 x 1.

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by