Size mismatch in matrix multiplications

1 次查看(过去 30 天)
I had some error in my Matlab function block but i can not solve ,please help me.
function Tl = fcn(e,s,t,Cl,gl)
lamda = 0.6; kt = 8; p = 0.8;ep=3;d=1.2;
w0 = 0.2+0.3*sin(15*t);
theta = [0.99; 0.12; 0.28; 1.02; 0.20];
theta0 = [0.56; 0.23; 0.19; 0.97; 0.18];
%Matrices of dynamic equation.
Ce = Cl/(1+0.2*sin(3*t));
ge = gl/(1+0.1*sin(4*t));
Yl = (Ce*lamda*e+ge)/theta;
% dieu kien theta
if norm(transpose(Yl).*s)> ep
Rotheta = -p*(transpose(Yl).*s/norm(transpose(Yl)*s));
else
Rotheta = -p*transpose(Yl).*s/ep;
end
% dieu kien cua w estimation
if norm(s) > ep
Row = d*s/norm(s);
else
Row = d*s/ep;
end
thetae = theta0 + Rotheta;
we = w0 + Row;
Tl = Yl*thetae - kt*s +we;
Errors: Size mismatch (size [5 x 1] ~= size [2 x 1]).
Function 'Robust Controller/Controller' (#74.318.334), line 15, column 9:
"transpose(Yl).*s"
Undefined function or variable 'Rotheta'. The first assignment to a local variable determines its class.
Function 'Robust Controller/Controller' (#74.562.569), line 27, column 19:
"Rotheta".
  5 个评论
dpb
dpb 2020-10-25
Well, now you have an orientation problem of a column vector and row vector. Again, matrix operations must follow rules for matrix algebra in having consistent dimensions for the respective operation.
We still don't know anything about the problem to be able to tell you which should be the transposed operation; you're the only one who knows the linear algebra behind what you're trying to code.
chuyen hoangcao
chuyen hoangcao 2020-10-25
can you help me glance at my simulation ? I just coded based on the number of paper and its structure.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics and Optimization 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by