MATLAB: Error on dsolve() line 201. Solving system of differential equations.

differentialdifferential equationssystem of differential equations

Long post warning.
Hi there. I'm new on Matlab. I've been watching YouTube videos for a week and I can't figure out the right way to solve an engineering problem. It's a Engeneering of chemical reactions problem.
Here are some screenshots of the problem, it was supposedly already solved on Polymath.
Some initial conditions here.
Here is the solution.
And here's what my teacher did on Polymath.
I want to learn how to use this tool properly and that's why I'm asking this. I have the following code I wrote myself, but it doesn't work.
%Se debe limpiar la pantalla
clear all;
clc;
%Se definen las variables que dependen de otras
%Commented out this because I'm not sure if they are needed
%syms kA(T) CA(x,y,T) CB(x,y,T) CC(X,y,T) kC(T) x(W) y(W) T(W);
syms x(W) y(W) T(W);
%Definir variables que no cambian... o sea, constantes
T0=325;
TA=325;
Ea=25000;
FA0=5;
FB0=FA0;
FI=FA0;
k=0.004; %a 310 K
Ke=1000; %a 303 K
DHRx=-20000;
alfa=0.0002;
Cp=20; CA=Cp; CB=Cp; CC=Cp; CpI=40;
UaRoB=0.5;
R=1.987;
Xeq=(Ke^(1/2))/(2+Ke^(1/2)); %Se obtiene con -rA = 0
y0=1/3; Ctot=0.3; CA0=y0*Ctot;
%Se declaran variables que dependen de otras
kA=k*exp((Ea/R)*(1/310-1/T));
kC=Ke*exp((DHRx/R)*(1/303-1/T));
CA=CA0*(1-x)*y*(T0/T);
CB=CA0*(1-x)*y*(T0/T);
CC=2*CA0*x*y*(T0/T);
rA=-kA*(CA*CB-((CC^2)/kC));
sCp=CA+CB+CC;
%Definir ecuaciones diferenciales
ode1 = diff(x) == -1*rA/FA0;
ode2 = diff(y) == -(alfa/2*y)*(T/T0);
ode3 = diff(T) == (UaRoB*(TA-T)+(-DHRx*-rA))/(FA0*sCp);
odes = [ode1;ode2;ode3];
%Se almacena solucion en una variable
Solucion = dsolve(odes);
%Extrae la función del arreglo de la solución
Solx(W) = Solucion.x
Soly(W) = Solucion.y
SolT(W) = Solucion.T
[Solx(W), Soly(W), SolT(W)] = dsolve(odes);
cond1 = x(0) == 0;
cond2 = y(0) == 1;
cond3 = T(0) == 325;
conds = [cond1; cond2; cond3];
[Solx(W), Soly(W),SolT(W)] = dsolve(odes,conds);
plot(y,W(:,1))
xlabel('Peso de catalizador (W)'),ylabel('y')
There is a problem on the solver, dsolve at line 201. On a help page from this site, I stumbled upong a very clear and easy-to-follow routine, but it doesn't seem to work with my specific case.
How can I improve the code and get the solutions? I feel dumb, but it's my first time dealing with this software.

Best Answer

Try
function main
z0=[0; 1; 325];
tspan = [0 2500];
[T Z]=ode15s(@myfun,tspan,z0);
plot(T,Z(:,1),'-o',T,Z(:,2),'-.',T,Z(:,3),'-*')
function dz = myfun(W,z)
x=z(1);
y=z(2);
T=z(3);
dz=zeros(3,1);
%Definir variables que no cambian... o sea, constantes
T0=325;
TA=325;
Ea=25000;
FA0=5;
FB0=FA0;
FI=FA0;
k=0.004; %a 310 K
Ke=1000; %a 303 K
DHRx=-20000;
alfa=0.0002;
Cp=20; CA=Cp; CB=Cp; CC=Cp; CpI=40;
UaRoB=0.5;
R=1.987;
Xeq=(Ke^(1/2))/(2+Ke^(1/2)); %Se obtiene con -rA = 0
y0=1/3; Ctot=0.3; CA0=y0*Ctot;
%Se declaran variables que dependen de otras
kA=k*exp((Ea/R)*(1/310-1/T));
kC=Ke*exp((DHRx/R)*(1/303-1/T));
CA=CA0*(1-x)*y*(T0/T);
CB=CA0*(1-x)*y*(T0/T);
CC=2*CA0*x*y*(T0/T);
rA=-kA*(CA*CB-((CC^2)/kC));
sCp=CA+CB+CC;
%Definir ecuaciones diferenciales
dz(1) = -1*rA/FA0;
dz(2) = -(alfa/2*y)*(T/T0);
dz(3) = (UaRoB*(TA-T)+(-DHRx*-rA))/(FA0*sCp);
Best wishes
Torsten.