Size mismatch in matrix multiplications

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 Commenti

dpb
dpb il 25 Ott 2020
Modificato: dpb il 25 Ott 2020
Ce = Cl/(1+0.2*sin(3*t));
ge = gl/(1+0.1*sin(4*t));
Yl = (Ce*lamda*e+ge)/theta;
all should probably use the "dot" ./ operator for element-wise division, not array division /
We can't tell for sure what should be what dimensions for your problem; the error is clear though, that you have mismatched array sizes. Clearly we can see the 5 elements for theta so presuming t is a scalar, that would produce the 5x1 array for Y.
Ergo, s would have to have commensurate dimensions for matrix operations--what it is we don't know, but that's the problem.
I added "dot" before '/' and it appeared this error.
Size mismatch (size [5 x 1] ~= size [1 x 5]).
Function 'Robust Controller 1/Controller' (#107.543.559), line 27, column 10:
"theta0 + Rotheta"
Moreover, thetae is undefined function.
The figures in theta i took from the simulation number of a paper, but i dont know why it has this error.In my oppinion , the dimesion of transpose(Yl)*s should be 2*1 because it is in norm.
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.
can you help me glance at my simulation ? I just coded based on the number of paper and its structure.

Accedi per commentare.

Risposte (0)

Prodotti

Richiesto:

il 25 Ott 2020

Commentato:

il 25 Ott 2020

Community Treasure Hunt

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

Start Hunting!

Translated by