-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathf_plot_ellipse.m
34 lines (27 loc) · 1.01 KB
/
f_plot_ellipse.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
34
function [e1,e2]=f_plot_ellipse(Xf_left,Xf_right)
%# substract mean
Mu = mean(Xf_left);
X0 = bsxfun(@minus, Xf_left, Mu);
%# eigen decomposition [sorted by eigen values]
[V D] = eig(cov(X0)); %#' cov(X0)
[D order] = sort(diag(D), 'descend');
D = diag(D);
V = V(:, order);
t = linspace(0,2*pi,200);
e = [cos(t) ; sin(t)]; %# unit circle
VV = V*sqrt(D)*2; %# scale eigenvectors
e1 = bsxfun(@plus, VV*e, Mu'); %#' project circle back to orig space
%
%# substract mean
Mu = mean(Xf_right);
X0 = bsxfun(@minus, Xf_right, Mu);
%# eigen decomposition [sorted by eigen values]
[V D] = eig(cov(X0)); %#' cov(X0)
[D order] = sort(diag(D), 'descend');
D = diag(D);
V = V(:, order);
t = linspace(0,2*pi,200);
e = [cos(t) ; sin(t)]; %# unit circle
VV = V*sqrt(D)*2; %# scale eigenvectors
e2 = bsxfun(@plus, VV*e, Mu'); %#' project circle back to orig space
end