Calculating a rotation matrix using rotate in Matl

2019-09-06 10:59发布

问题:

I'm using Matlab 2013a on Windows 7 Pro 64 bit.

In 2010 (using a different version of Matlab), I wrote the following code to calculate a 3x3 rotation matrix

C=rotate (omega, i, w);
R=C*Ro;

where omega, i, and w are rotation angles in radians. On my current system, giving the example input of omega = i = w = 0, C will be a 3x3 identity matrix.

If I copy the code into another directory that I wrote in the past few months, the same code will result in the following error.

Error using rotate
Too many output arguments.

So my question to SO is why the same lines of code on the same computer with the same version of Matlab will work in one directory but not in another directory?

回答1:

If you had read the help for rotate, you would have seen that this one does not calculate the rotation matrix, but rotates a matlab graph. Some toolboxes eg Phased Array System Toolbox have some functions rotx, roty,... to calculate the rotational matrix.

However, functions for calculating the rotation matrix is not that hard to construct. Looking at http://en.wikipedia.org/wiki/Rotation_matrix the rotational matrices for every axis is given. The general rotation matrix is then a product of the individual rotation matrices. This should be piece of cake.