Take a closer look on example from MATLAB help
I suggest you to comment these lines (or remove) since you are using odeToVectorField
% F = @(t,Y,k1,k2,m1,m2) [Y(2);...
% -(k2.*Y(1)-k1.*Y(3))./m2;...
% Y(4);...
% -(-k2.*Y(1)+k1.*Y(3)+k2.*Y(3))./m1];
Also define your constants BEFORE equations
Use something like that to define or add variables from your ode function
syms t Y
F = matlabFunction(SymSys,'vars',[t Y])