1
votes

I am trying to solve a system of 6 differential equations using matlab. I created a set of 6 differential equations as follows in a function m file named as Untitled.m

function ydot=Untitled(z,y)
ydot = zeros(6,1);
%y(1)=A
%y(2)=B
%y(3)=C
%y(4)=D
%y(5)=P
y(6)=T

A=0.50265
k11=(333/106.7)*1.15*1000*exp(-59660/(8.314*960))
k31=(333/40)*73.6*exp(-47820/(8.314*960))
k32=(333/14.4)*1.79*exp(-30950/(8.314*960))
k21=(106.7/40)*426*exp(-68830/(8.314*960))
k22=(106.7/14.4)*0.000599*exp(-57740/(8.314*960))
Pcat=1450
g=9.81
phi=exp(-al*tc)
al=59100*exp(-67210/(8.314*T))
tc=(0.50265*1450*33)/143.64
H11=393000
H31=795000
H32=1200000
H21=1150000
H22=151000
E=1-((285.765*17.56)/((6.1*1450)+(17.56*285.765)))
Fcat=143.64
Cpcat=1087
Cp=1000*(y(1)*3.3+y(2)*3.3+y(3)*3.3+y(4)*1.087)
F=19.95
ydot(1)= -(A*(1-E)*Pcat*(k11+k31+k32)*phi*y(1)*y(1))/F
ydot(2)=  (A*(1-E)*Pcat*(k11*y(1)*y(1)-(k21+k22)*y(2))*phi)/F
ydot(3)=  (A*(1-E)*Pcat*(k31*y(1)*y(1)+ k21*y(2))*phi)/F
ydot(4)=  (A*(1-E)*Pcat*(k32*y(1)*y(1)+k22*y(2))*phi)/F
ydot(5)= -(Pcat*g*(1-E))
ydot(6) = ((phi*(1-E)*Pcat*A)*(y(1)*y(1)((k11*H11)+(k31*H31)+(k32*H32))+y(2)((k21*H21)+    (k22*H22)))/((F*Cp)+(Fcat*Cpcat)))


%UNTITLED Summary of this function goes here
%   Detailed explanation goes here

then i have created another file for using the ODE45 solver to solve the equations

function main
options = odeset('RelTol',1e-6); %,'AbsTol',[1e-5 1e-5 1e-5 1e-5 1e-5 1e-5 ]);
Y0=[1.0;0.0;0.0;0.0;180000.0;959.81]
zspan=0:0.5:33;
[z,y]= ode45(@Untitled,zspan,Y0,options);
figure
hold on
plot(z,y(:,1));
plot(z,y(:,2),':');

but I am getting errors

??? Error using ==> feval
Error: File: Untitled.m Line: 41 Column: 37
()-indexing must appear last in an index expression.
Error in ==> odearguments at 110
f0 = feval(ode,t0,y0,args{:});   % ODE15I sets args{1} to yp0.
Error in ==> ode45 at 173
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in ==> ode at 6
[z,y]= ode45(@Untitled,zspan,Y0,options);

could anyone please help me with this as it is really important for me and i am new to MATLAB

thanx in advance :)

1

1 Answers

2
votes

Search for )( in your code, it's syntactically not allowed. Probably you missed a * in between.