Hello,
I have a position vector q=[x y z].' I want to compute the following: Q=q*q.' . The dimension of Q is 3x3 . I'd like to do this operation for multiple position vectors at once, say q1=[x1 y1 z1] and q2=[x2 y2 z2], resulting in a Q1 and Q2 matrix. The outcome may be a 3D matrix, in this case with dimension 3x3x2. Is there a way to this without using a for-loop? Thanks in advance.
Jeroen

 채택된 답변

Andrei Bobrov
Andrei Bobrov 2013년 4월 16일
편집: Andrei Bobrov 2013년 4월 16일

0 개 추천

q = reshape(1:6,[],2); % let your vectors as [q1,q2]
s = size(q,1);
Q = bsxfun(@times,reshape(q,s,1,[]),reshape(q,1,s,[]));
or
qq = repmat(permute(q,[1 3 2]),1,s);
Q = qq.*permute(qq,[2 1 3]);

댓글 수: 1

Jeroen van Gemert
Jeroen van Gemert 2013년 4월 16일
Thanks a lot for the quick response and the helpful answer!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Execution Speed에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by