How to convert a matrix of vectors in a matrix of skew symmetric matrices

16 views (last 30 days)
I have a mxnx3 dimensional matrix (for example, 1000X2000 points represented by their x,y,z coordinates). I want to convert the last 3 dimensional vector into a skew symmetric matrix. I know that I can convert a single vector of size 3 in a skew symmetric matrix of size 3x3 as follows:
X = [ 0 -x(3) x(2) ;
x(3) 0 -x(1) ;
-x(2) x(1) 0 ];
Now, I can go write a for loop and go through each of mxn elements and convert them by the aforementioned method into a skey symmetric matrix. I was wondering, how to write this code in vectorised manner, so that I can run this quickly.
  2 Comments
Amjad Green
Amjad Green on 10 Apr 2018
there isn't a direct command to skew vector,you will have to write a for loop to do it,i suggest first making a matrix of 3*x size and running the for loop on it

Sign in to comment.

Accepted Answer

the cyclist
the cyclist on 10 Apr 2018
I think this does what you want
% Set the random seed, for replicability
rng default
% Generate some pretend data
M = 2;
N = 4;
ij3 = rand(M,N,3);
% Initialize the skew array
ij33 = zeros(M,N,3,3);
% Populate the skew array
ij33(:,:,1,2) = -ij3(:,:,3);
ij33(:,:,2,1) = ij3(:,:,3);
ij33(:,:,1,3) = ij3(:,:,2);
ij33(:,:,3,1) = -ij3(:,:,2);
ij33(:,:,2,3) = -ij3(:,:,1);
ij33(:,:,3,2) = ij3(:,:,1);

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!