Why does my code get a non singleton error?

I key in this code
if true
% qe=zeros(2001,1);
qe(1) = q_start(1);
qs=zeros(2001,1);
qs(1) =q_start(2);
qdote = zeros(2001,1);
qdote(1)=0;
qdots=zeros(2001,1);
qdots(1)=0;
qddote=zeros(2001,1);
qddots=zeros(2001,1);
qddot=[qddote qddots];
tau1be=zeros(2001,1);
tau1bs=zeros(2001,1);
tau1b=[tau1be tau1bs];
c1e= cos(qe(1));
c1s=cos(qs(1));
%set starting values of mass matrix
h22= I(1) + m(1)*cL(1)^2;
h11= I(1)+I(2)+m(2)*cL(2)^2+m(1)*(l(2)^2*cL(1)^2-2*l(2)*cL(1)*c1e);
h12= I(1)+m(1)*(cL(1)^2+l(2)*cL(1)*c1e);
H= [h11, h12; h12, h22];
l1= l(1); l2= l(2);
q1= qb(1); q12= q1;
c1e= cos(q1); s1= sin(q1);
c12= cos(q12); s12= sin(q12);
xe=zeros(2001,1);
xs=zeros(2001,1);
xe(1)= l1*c1e + l2*c12;%start displacement matrix
xs(1)=l1*s1+l2*s12;
s2= sin(0);
i=1:2001;
t=i/100;
x2(1)=l1*cos(q_start(1))+l2*cos(q_start(1)+q_start(2));
y2(1)=l1*sin(q_start(1))+l2*sin(q_start(1)+q_start(2));
for i=1:2000 %set up loop
if i<200 %before 2 seconds, torque equation is as follows
tau1be(i)=0.02-0.1*qdote(i);
tau1bs(i)=-0.1*qdots(i);
end
if i>201%after 2 seconds, torque equation is as follows
tau1be(i)=-0.1*qdotb(i);
tau1bs(i)=-0.1*qdots(i);
end tau1b(i,:)=[tau1be(i) tau1bs(i)]; % Integration functions C= zeros(2,1); p= m(2)*l(1)*cL(2)*s2; C(1)= m(1)*l(2)*cL(2)*qdote(i)*(2*qdots(i)-qdote(i))*sin(qe(i)); C(2)= m(1)*l(2)*cL(2)*qdote(i)*(qdote(i)).*sin(qe(i)); UpdateAngle = @(q,qdot)([q+dt*qdot]);
UpdateVel = @(qdot,qddot)([qdot+dt*qddot]);
JointAccel = @(Torque,H,Cqdot)(H\(Torque-Cqdot)); %find angle acceleration
updatepos = @(x,qdot)(x+dt*qdot); % Compute dynamic
qddot(i+1,:) = JointAccel(tau1b(i,:),H,C);
end
but it reads in response
if true
% Assignment has more non-singleton rhs dimensions than non-singleton subscripts
Error in betterq1bcode (line 73) qddot(i+1,:) = JointAccel(tau1b(i,:),H,C);end even though applying such a code to a single row matrix works perfectly. What causes the error?

Answers (0)

Categories

Find more on Simulink in Help Center and File Exchange

Asked:

on 18 Feb 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!