matlab robotic toolbox 仿真多足机器人报错,如何解决?

打算依照这篇文章
https://blog.csdn.net/weixin_44609769/article/details/118678752
的最后一部分的代码,试着做出改变机器人身体和四条腿的坐标来到达移动的效果的一个简单例子。

实际运行代码如下

L1 = 0.1; L2 = 0.1;


links(1) = Link([    0       0    0   pi/2 ], 'standard');
links(2) = Link([    0       0    L1   0   ], 'standard');
links(3) = Link([    0       0   -L2   0   ], 'standard');


leg = SerialLink(links, 'name', 'leg', 'offset', [pi/2   0  -pi/2]);


xf = 5; xb = -xf;   
y = 5;              
zu = 2; zd = 5;     

segments = [xf y zd; xb y zd; xb y zu; xf y zu] * 0.01;


segments = [segments; segments];
tseg = [3 0.25 0.5 0.25]';
tseg = [1; tseg; tseg];
x = mstraj(segments, [], tseg, segments(1,:), 0.01, 0.1);


xcycle = x(100:500,:);
qcycle = leg.ikine( transl(xcycle), [], 'mask',[1 1 1 0 0 0], 'pinv' );

plotopt = {'noraise', 'nobase', 'noshadow', 'nowrist', 'nojaxes', 'delay', 0};
    clf; axis([-0.3 0.1 -0.2 0.2 -0.15 0.05]); set(gca,'Zdir', 'reverse')
hold on


while 1
    
    % 调整视窗角度
    view(51,48)
    
    % 刷新身体和腿的位置
    % 从而达到身体移动的效果
    if(mod(k,10)==0)
    delete(row)
    W = 0.1; L = 0.2;
    % 创建4条腿的机器人。每条腿都是我们上面造的腿机器人的克隆,
    % 通过'base'基变换将四条腿安装在身体的四个角

    legs(1) = SerialLink(leg, 'name', 'leg1', 'base', transl(0+k/6000, 0, 0));
    legs(2) = SerialLink(leg, 'name', 'leg2', 'base', transl(-L+k/6000, 0, 0));
    legs(3) = SerialLink(leg, 'name', 'leg3', 'base', transl(-L+k/6000, -W, 0)*trotz(pi));
   legs(4) = SerialLink(leg, 'name', 'leg4', 'base', transl(0+k/6000, -W, 0)*trotz(pi));


% 通过补片绘制机器人身体
    cube=patch([0+k/6000 -L+k/6000 -L+k/6000 0+k/6000 ], [0 0 -W -W ], [0 0 0 0], 'FaceColor', 'r', 'FaceAlpha', 0.5);
    row=cube;
    hold off
    % 画出四条腿
    for i=1:4
    legs(i).plot(qcycle(1,:), plotopt{:});
    end
    hold off
    end
    
    
    legs(1).animate( gait(qcycle, k, 0,   0))
    legs(2).animate( gait(qcycle, k, 100, 0))
    legs(3).animate( gait(qcycle, k, 200, 1))
    legs(4).animate( gait(qcycle, k, 300, 1))
    drawnow
    k = k+1;
end


img

不论怎么修改始终报这个错误。不知道如何解决,求指点