【发布时间】:2011-11-18 00:40:29
【问题描述】:
我得到了一个可以使用的旋转矩阵:
并将矩阵输入到我的函数中
theta = radians(theta);
Ry(theta) = [cos(theta) 0 sin(theta); 0 1 0; -sin(theta) 0 cos(theta)];
newpose = pos*Ry(theta);
然而每当函数到达这个阶段它就会返回错误
???下标索引必须是实数正整数或 逻辑。
非常感谢任何帮助
【问题讨论】:
我得到了一个可以使用的旋转矩阵:
并将矩阵输入到我的函数中
theta = radians(theta);
Ry(theta) = [cos(theta) 0 sin(theta); 0 1 0; -sin(theta) 0 cos(theta)];
newpose = pos*Ry(theta);
然而每当函数到达这个阶段它就会返回错误
???下标索引必须是实数正整数或 逻辑。
非常感谢任何帮助
【问题讨论】:
Ry(theta)
theta 很可能不是正整数或逻辑整数。
【讨论】:
问题是Ry(theta)。如果您希望它是一个变量,可以将其称为 Ry_theta 之类的名称,或者将其放入实际函数中。这应该有效:
theta = radians(theta);
Ry_theta = [cos(theta) 0 sin(theta); 0 1 0; -sin(theta) 0 cos(theta)];
newpose = pos*Ry_theta;
或者 - 如果您想要更可重用的解决方案:
% in your existing file:
theta = radians(theta);
newpose = pos*rotationAboutYAxis(theta);;
% in a file called rotationAboutYAxis.m:
function Ry = rotationAboutYAxis(theta)
Ry = [cos(theta) 0 sin(theta); 0 1 0; -sin(theta) 0 cos(theta)];
【讨论】: