Size mismatch (size [1 x 3] ~= size [3 x 1]).
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I am getting the following error:
Size mismatch (size [1 x 3] ~= size [3 x 1]).
Function 'Controllers/Nonlinear_Controller' (#551.836.851), line 35, column 10:
"w_B_IB + w_O*c2"
My code is below and attached is my simulink diagram.
global w_O
q_acc_d = in(1:4);
q_dot_d = in(5:8);
q_d = in(9:12);
x_dot = in(13:19);
x = in(20:26);
eta_acc_d = q_acc_d(1);
epsilon_acc_d = q_acc_d(2:4);
eta_dot_d = q_dot_d(1);
epsilon_dot_d = q_dot_d(2:4);
eta_d = q_d(1);
epsilon_d = q_d(2:4);
eta_dot = x_dot(1);
epsilon_dot = x_dot(2:4);
w_B_IB_dot = x_dot(5:7);
eta = x(1);
epsilon = x(2:4);
w_B_IB = x(5:7);
% Transforming from w_B_IB to w_B_OB
q = [eta; epsilon(1); epsilon(2); epsilon(3)];
R_O_B = Rquat(q);
R_B_O = R_O_B';
c2 = R_B_O(:,2);
w_B_OB = w_B_IB + w_O*c2;global w_O
q_acc_d = in(1:4);
q_dot_d = in(5:8);
q_d = in(9:12);
x_dot = in(13:19);
x = in(20:26);
eta_acc_d = q_acc_d(1);
epsilon_acc_d = q_acc_d(2:4);
eta_dot_d = q_dot_d(1);
epsilon_dot_d = q_dot_d(2:4);
eta_d = q_d(1);
epsilon_d = q_d(2:4);
eta_dot = x_dot(1);
epsilon_dot = x_dot(2:4);
w_B_IB_dot = x_dot(5:7);
eta = x(1);
epsilon = x(2:4);
w_B_IB = x(5:7);
% Transforming from w_B_IB to w_B_OB
q = [eta; epsilon(1); epsilon(2); epsilon(3)];
R_O_B = Rquat(q);
R_B_O = R_O_B';
c2 = R_B_O(:,2);
w_B_OB = w_B_IB + w_O*c2;
I am getting this error and can't figure it out. The same error is occurring in the sliding_mode and nonlinear_controller scripts. Anyone know what could be going on?
1 Commento
Risposte (1)
Walter Roberson
il 10 Giu 2017
We do not know whether in is a column vector or a row vector, but probably it is a row vector. That would make x = in(20:26); a row vector, and then that would make w_B_IB = x(5:7); a 1 x 3 row vector.
We do not know the size of Rquat but we can see from
R_O_B = Rquat(q);
R_B_O = R_O_B';
c2 = R_B_O(:,2);
that c2 will be a column vector. We can deduce from the evidence that it is 3 x 1.
We do not know the size of w_O but we can deduce from the evidence that it is 3 x 3.
w_B_IB + w_O*c2 would then be (1 x 3) + (3 x 3) * (3 x 1) . The (3 x 3) * (3 x 1) would then give a 3 x 1 output, leaving you with (1 x 3) + (3 x 1) which is not permitted in R2016a or earlier. In R2016b or later, I do not know if (1 x 3) + (3 x 1) is supported in MATLAB Function Block: if it were supported it would give a 3 x 3 result. If that is what you want to happen, then it is safer to use bsxfun(@plus, w_B_IB, w_O*c2)
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!