How to perform vector Matrix Multiplication

조회 수: 21 (최근 30일)
M Biggs
M Biggs 2018년 2월 23일
답변: James Tursa 2018년 2월 23일
I need to multiply a time series of 4x4 matrices by a corresponding Time series of 4x4 transformation matrices. I am looking for the most efficient method without a for loop.
P_new = T * P
where: P is a nx4x4 matrix, where n is the number of time epochs.
T is a nx4x4 transformation matrix, where n is the number of time steps.
P_new is a nx4x4 version of P that is transformed.
In a loop I would do for i=1:n; P_new(i,1:4,1:4) = T(i,1:4,1:4) * P(i,1:4,1:4); end
How could I do this outside a loop??

답변 (1개)

James Tursa
James Tursa 2018년 2월 23일
First I would suggest you reorder your dimensions to put the 4x4 matrices first, so that P is 4x4xn and T is 4x4xn. That way all of your 4x4 matrices are contiguous in memory. Then you have some options from the FEX (some of which are mex functions that require a C compiler):

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by