# 3-DOF Robot Dynamics error in Robotics Toolbox

I am trying to compute dynamics of 3 DOF robot using Robotics Toolbox by executing this code:

robot.accel(q, zeros(1,3), zeros(1,3))


But I am getting this error: Assignment has more non-singleton rhs dimensions than non-singleton subscripts

My robot is:

L(1)= Link([0 0.03 0 -pi/2]);
L(1).m = 1;
L(2).m = 4;
L(3).m = 3;
L(1).r=[0 0 -0.015];
L(2).r=[0.14 0 0];
L(3).r=[0.1 0 0];

ax1=0.03; ay1=0.03; az1=0.03;
ax2=0.28; ay2=0.05; az2=0.05;
ax3=0.2; ay3=0.05; az3=0.05;
I1=1/12*[ay1^2+az1^2 0 0; 0 ax1^2+az1^2 0; 0 0 ax1^2+ay1^2];
I2=4/12*[ay2^2+az2^2 0 0; 0 ax2^2+az2^2 0; 0 0 ax2^2+ay2^2];
I3=3/12*[ay3^2+az3^2 0 0; 0 ax3^2+az3^2 0; 0 0 ax3^2+ay3^2];
L(1).I=I1;
L(2).I=I2;
L(3).I=I3;

q=[0 0 0]



This is not a great error message and it only happens if you are using the MATLAB rather than the (100x) faster MEX version of the dynamics.

The error occurs because the motor inertias are not set, and they default to []. To fix this I ran this code after the robot was defined

>> for i=1:3
end


but you could build it into your initialisation code. The acceleration is

>> robot.accel(q, zeros(1,3), zeros(1,3))

ans =

-0.0000
22.6479
-11.5237

• Thanks! Exactly what was needed. – Capri Jul 16 '19 at 7:29