-
Notifications
You must be signed in to change notification settings - Fork 1
/
vee.m
33 lines (23 loc) · 690 Bytes
/
vee.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function vec = vee(ss)
% function vec = vee(skewsymmetric)
% The vee function maps a skew-symmetric
% matrix to a vector
if isa(ss,'sym')
ss = expand(simplify(ss));
end
switch numel(ss)
case 4
if ~isequal(ss(1,2), -ss(2,1))
warning('The provided matrix is not skew symmetric')
end
vec = ss(1,2);
case 9
if ~isequal(ss(3,2),-ss(2,3)) || ~isequal(ss(1,3),-ss(3,1)) || ~isequal(ss(2,1),-ss(1,2))
warning('The provided matrix is not skew symmetric.')
end
vec = [ss(3,2); ss(1,3); ss(2,1)];
end
if isa(ss,'sym')
vec = simplify(vec);
end
end