MATLAB: Ode solver returns too many results

ode

I am trying to solve a system of ode's with ode15s but it is not working properly. It is returning a vector of length 9 for my system of 3 ode's instead of 3 as I desire. My system looks like this
function D = mo(t,y,a,b)
dy = a*y;
dv= (a*t+1)*y;
dw = (a/b)*y;
D = [dy; dv; dw];
And this is how I am trying to solve it
x0(1) = 0.2;
x0(2)= 4;
ts = [0,1,2,3,4,5];
options = odeset('RelTol',1e-8,'AbsTol',1e-8);
[~,y] = ode15s(@(t,y) mo(t,y,x0(1),x0(2)),ts,[x0(2) 0 1],options);
I have no clue why I get this error
Error using odearguments (line 95)
@(T,Y)MO(T,Y,X0(1),X0(2)) returns a vector of length 9, but the length of initial conditions vector is 3. The vector returned by
@(T,Y)MO(T,Y,X0(1),X0(2)) and the initial conditions vector must have the same number of elements.
Edit1: I had a typo in dw
Edit2: Just for clarification the result I want to get can be retrieved with wolfram alpha:

Best Answer

The problem is that ‘y’ is a (3x1) vector, and ‘mo’ is evaluating each value for all values of ‘y’.
Perhaps you intend:
function D = mo(t,y,a,b)
dy = a*y(1);
dv= (a*t+1)*y(2);
dw = (a/b+1)*y(3);
D = [dy; dv; dw];
end
or as an anonymous function:
mo = @(t,y,a,b) [a*y(1); (a*t+1)*y(2); (a/b+1)*y(3)];
.