I only see two variables, θ1 and θ2, and each is part of a 2nd order equation. So that would mean a 2 x 2 = 4 element state vector, not 6 element state vector as you are using. E.g., I would have the states defined as
y(1) = 
y(2) = 
y(3) = 
y(4) = 
which would mean the derivative function would be:
function dydt = ODEsystem(t,y)
theta1ddot = k/J1 * y(1) - k/J1 * y(2);
theta2ddot = b/J2 * y(4) + k/J2 * y(2) - k/J2 * y(1);
dydt = [y(3);y(4);theta1ddot;theta2ddot];