【问题标题】:Matrix multiplication of 3D matrix with rotation matrix3D矩阵与旋转矩阵的矩阵乘法
【发布时间】:2016-04-21 20:51:19
【问题描述】:

我有一个N x M x 3 矩阵,它代表N*M 方向向量。我想将每个方向向量与 3 x 3 旋转矩阵相乘,以获得新坐标系中的向量。如何在 MATLAB 中做到这一点而不使用 for 循环?

【问题讨论】:

  • 很可能你可以使用matrix-multiplication。你用循环试过了吗?如果有,分享一下?

标签: matlab


【解决方案1】:

您可以利用reshape 将您的N x M x 3 矩阵转换为(N*M) x 3,然后乘以您的旋转矩阵R,然后将reshape 的结果返回为N x M x 3

%// Create some example data and a rotation matrix
data = rand(5,4,3);
R = rand(3);

%// Apply rotation to 3D data matrix.
newdata = reshape(reshape(data, [], 3) * R, size(data));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-01-24
    • 2016-12-11
    • 2016-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多