필터 지우기
필터 지우기

size mismatch in matlab function block

조회 수: 1 (최근 30일)
chuyen hoangcao
chuyen hoangcao 2020년 10월 28일
편집: Walter Roberson 2020년 10월 29일
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);

채택된 답변

Fangjun Jiang
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
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.
chuyen hoangcao
chuyen hoangcao 2020년 10월 29일
it ran when i delete '.' in front of inv 'Ml'.Thank you

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 General Applications에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by