-
Notifications
You must be signed in to change notification settings - Fork 0
/
mvdemo6.m
53 lines (45 loc) · 1.59 KB
/
mvdemo6.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
% $Id: mvdemo6.m,v 1.2 2001/12/04 09:24:17 rune Exp $
% Script for testing the mvartools package
%
% MVARTOOLS, Copyright (C) 1999-2001 Rune Mathisen <[email protected]>
% MVARTOOLS comes with ABSOLUTELY NO WARRANTY; for details type
% `mvwarranty'. This is free software, and you are welcome to
% redistribute it under certain conditions; type `mvcopying' for
% details. For more information on MVARTOOLS, type 'mvreadme'.
disp('Demonstration of the mvdensityplot function.')
disp('This function is useful when visualizing large amount of data.')
% create data
xvars=0:0.1:2*pi;
x1 = sin(2*xvars);
x2 = sin(2*xvars+1);
x3 = sin(3*xvars);
x4 = sin(3*xvars+1);
%plot(1:length(xvars),[x1' x2' x3' x4'])
disp('Constructing data matrix...')
X(1:1000,:) = 4*randn(1000,1)*x1 ...
+ randn(1000,1)*x2 ...
+ randn(1000,1)*x3 ...
+ randn(1000,1)*x4;
X(1001:2000,:) = randn(1000,1)*x1 ...
+ 4*randn(1000,1)*x2 ...
+ randn(1000,1)*x3 ...
+ randn(1000,1)*x4;
X(2001:3000,:) = randn(1000,1)*x1 ...
+ randn(1000,1)*x2 ...
+ 4*randn(1000,1)*x3 ...
+ randn(1000,1)*x4;
X(3001:4000,:) = randn(1000,1)*x1 ...
+ randn(1000,1)*x2 ...
+ randn(1000,1)*x3 ...
+ 4*randn(1000,1)*x4;
disp('Doing PCA...')
[T,P,eigv,varpc,RES] = mvpcasvd(mvcenter(X),4);
disp('Plotting may take some time, please wait...')
figure
mvdensityplot(T(:,1),T(:,2))
colormap(hot)
xlabel('PC1')
ylabel('PC2')
%figure
%mvscoreplot(T,1,2)
%end of file