Vertcat error when Im not using vertcat

조회 수: 19 (최근 30일)
Tina Barsoumian
Tina Barsoumian 2020년 2월 24일
댓글: Stephen23 2020년 2월 24일
I am working on a rotational robot homogeneous transformation matricies but I keep getting a vertcat error when Im only multiplying mtrices of the same size. This code was working two weeks ago but all of sudden, its getting a vertcat error. Here is my code:
function H = H(theta1, theta2, theta3) %creating homogeneous function
%--------------------------
%--------------------------
H = (Rx(-90)*Rz(theta1)*Tz(0.25))*(Rz(theta2)*Tx(0.4))*(Rz(theta3)*Tx(0.4));
%there are other parts of this function that simply plot parts of H that I don't belevie are necessary here
end
%basic transformation functions
%Rotational martices
function [Rx] = Rx(a) %creating functoin Rx
Rx = [1 0 0 0; %defining function Rx
0 cosd(a) -sind(a) 0;
0 sind(a) cosd(a) 0;
0 0 0 1];
end
function [Ry] = Ry(b) %creating functoin Ry
Ry = [cosd(b) 0 sind(b) 0; %defining function Ry
0 1 0 0;
-sind(b) 0 cosd(b) 0;
0 0 0 1];
end
function [Rz] = Rz(g) %creating functoin Rz
Rz = [cosd(g) -sind(g) 0 0; %defining function Rz
sind(g) cosd(g) 0 0;
0 0 1 0;
0 0 0 1];
end
%Tranlational matrices
function [Tx] = Tx(a) %creating functoin Tx
Tx = [1 0 0 a; %defining function Tx
0 1 0 0;
0 0 1 0;
0 0 0 1];
end
function [Ty] = Ty(b) %creating functoin Ty
Ty = [1 0 0 0; %defining function Ty
0 1 0 b;
0 0 1 0;
0 0 0 1];
end
function [Tz] = Tz(c) %creating functoin Tz
Tz = [1 0 0 0; %defining function Tz
0 1 0 0;
0 0 1 c;
0 0 0 1];
end
  댓글 수: 3
Tina Barsoumian
Tina Barsoumian 2020년 2월 24일
YES! that is it, thank you!
Stephen23
Stephen23 2020년 2월 24일
"Vertcat error when Im not using vertcat"
Actually indirectly you are. This shorthand syntax using square brackets:
[A;B]
calls vertcat to actually perform the concatenation.
As Jacob Wood asked about, the error most likely occurs because some of the arrays you are trying to concatenate are not scalar.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by