size mismatch in matlab function block
조회 수: 1 (최근 30일)
이전 댓글 표시
i dont know why there are some errors about size mismatch in my code, because as you can see, variable s has dimension is [1,2],Cl is [2,2] .Therefore i think the result will be [1,2] ,but it doesnt work.Please help me.
My code:
function [Cl,gl,ds] = fcn(q1,q2,dq2,dq1, Tl,Th,de,e,s,t)
%Matrices of dynamic equation.
a = 1.024;b = 0.24;Ro = 0.16;
g = 9.8;
Ml = [a+2*b*cos(q2) Ro+b*cos(q2); Ro+b*cos(q2) Ro];
Cl = [-2*b*sin(q2)*dq2 -b*sin(q2)*dq2; b*sin(q2)*dq1 0];
gl = [2.5*g*Ro*cos(q1+q2)+1.67*0.864*cos(q1) 2.5*g*Ro*cos(q1+q2)];
lamda = 0.6; ep = 3;d =1.2;
theta = [0.99; 0.12];
wl = 0.3+0.2*sin(2*t)+0.3*sin(20*t) - 0.2*sin(10*t)+ 0.3*sin(21*t);
w0 = 0.2 + 0.3*sin(15*t);
% dieu kien cua w estimation
if norm(s) > ep
Row = d*s./norm(s);
else
Row = d*s./ep;
end
we = w0 + Row;
% el(t) = -e(t);
Yl =( - de*Ml*lamda - e*Cl*lamda +gl);
ds =(-de*Ml*lamda -s*Cl - Yl*theta -(2*we-wl)+Tl+Th).*inv(Ml);
댓글 수: 0
채택된 답변
Fangjun Jiang
2020년 10월 28일
편집: Fangjun Jiang
2020년 10월 28일
[1 2]*[2 2; 2 2] is correct.
[1 2].*[2 2; 2 2] is wrong (without implicit expansion)
댓글 수: 3
Fangjun Jiang
2020년 10월 28일
take a particular set of values for all the input arguments, run the code line by line, stop at the line where the error occured, run indivudual section of that line of code if necessary, you will find where and what caused the error.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 General Applications에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!