在Matlab中使用旋转计算旋转矩阵 [英] Calculating a rotation matrix using rotate in Matlab

查看:1994
本文介绍了在Matlab中使用旋转计算旋转矩阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在64位Windows 7 Pro上使用Matlab 2013a.

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

2010年(使用其他版本的Matlab),我编写了以下代码来计算3x3旋转矩阵

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;

其中,ω,i和w是弧度的旋转角度.在我当前的系统上,给定示例输入omega = i = w = 0,C将是一个3x3的恒等矩阵.

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的疑问是,为什么同一台计算机上具有相同版本的Matlab的同一行代码可以在一个目录中工作,而在另一个目录中却不能工作?

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?

推荐答案

如果您已经阅读了rotate的帮助,您会发现它不计算旋转矩阵,而是旋转matlab图.某些工具箱(例如相控阵系统工具箱)具有一些功能rotx, roty,...来计算旋转矩阵.

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.

但是,构建旋转矩阵的函数并不难构建.查看 http://en.wikipedia.org/wiki/Rotation_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.

这篇关于在Matlab中使用旋转计算旋转矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆