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
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.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Mathematics and Optimization についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!