1

I have been provided with a rotation matrix to use:

matrix

and have entered the matrix into my function as

theta = radians(theta);
Ry(theta) = [cos(theta) 0 sin(theta); 0 1 0; -sin(theta) 0 cos(theta)];
newpose = pos*Ry(theta);

yet whenever the function reaches this stage it returns the error

??? Subscript indices must either be real positive integers or logicals.

any help much appreciated

Amro
  • 123,847
  • 25
  • 243
  • 454
Jordan
  • 25
  • 1
  • 3
  • Also see [this question](http://stackoverflow.com/questions/20054047/subscript-indices-must-either-be-real-positive-integers-or-logicals-generic-sol) for [the generic solution to this problem](http://stackoverflow.com/a/20054048/983722). – Dennis Jaheruddin Nov 27 '13 at 16:06

2 Answers2

1

The problem is the Ry(theta). Call it something like Ry_theta if you want it to be a variable, or put it in an actual function. This should work:

theta = radians(theta);
Ry_theta = [cos(theta) 0 sin(theta); 0 1 0; -sin(theta) 0 cos(theta)];
newpose = pos*Ry_theta;

Or - if you want a more reusable solution:

% 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)];
dantswain
  • 5,427
  • 1
  • 29
  • 37
0
Ry(theta) 

theta is most likely not a real positive integer or a logical.

John
  • 5,735
  • 3
  • 46
  • 62