[37] | 1 | function sdedemo; |
---|
| 2 | %sdeDemo tests SDE with a simple spiral consisting of 100 points. |
---|
| 3 | %please accustom the code to your SDP solver (CSDP/SEDUMI) |
---|
| 4 | % |
---|
| 5 | %function sdeDemo; |
---|
| 6 | % |
---|
| 7 | %tt=linspace(0,4*pi,100); |
---|
| 8 | %X=[tt.*sin(tt);tt.*cos(tt)]; |
---|
| 9 | %figure; |
---|
| 10 | %subplot(2,1,1); |
---|
| 11 | %scatter(X(1,:),X(2,:),'o',tt,'filled'); axis equal; |
---|
| 12 | %title('Original'); |
---|
| 13 | %drawnow; |
---|
| 14 | %try |
---|
| 15 | % [Y,D]=sdeCSDP(X); % CSDP |
---|
| 16 | % fprintf('Seems like sdeCSDP is working!\n'); |
---|
| 17 | %catch |
---|
| 18 | % [Y,D]=sdeNT(X); % SEDUMI |
---|
| 19 | % fprintf('Seems like sdeSeDuMi is working!\n'); |
---|
| 20 | %end; |
---|
| 21 | %subplot(2,1,2); |
---|
| 22 | %scatter(Y(1,:),Y(2,:),'o',tt,'filled'); axis equal |
---|
| 23 | %title('Reduced Dimensionality'); |
---|
| 24 | |
---|
| 25 | tt=linspace(0,4*pi,100); |
---|
| 26 | X=[tt.*sin(tt);tt.*cos(tt)]; |
---|
| 27 | %X=X-repmat(mean(X,2),1,length(X)); |
---|
| 28 | figure; |
---|
| 29 | pars.slack=1; |
---|
| 30 | |
---|
| 31 | try |
---|
| 32 | fprintf('Computing distances...'); |
---|
| 33 | Dis=distance(X); |
---|
| 34 | fprintf('done\n'); |
---|
| 35 | catch |
---|
| 36 | error('ERROR! Are you sure distance.m is in the path?'); |
---|
| 37 | |
---|
| 38 | end; |
---|
| 39 | |
---|
| 40 | subplot(2,1,1); |
---|
| 41 | scatter(X(1,:),X(2,:),60,tt,'filled'); axis equal; |
---|
| 42 | title('Original'); |
---|
| 43 | drawnow; |
---|
| 44 | try |
---|
| 45 | pars.solver=0; |
---|
| 46 | [Y,D]=sde(Dis,3,pars); % CSDP |
---|
| 47 | fprintf('\n\nCSDP is working!\n'); |
---|
| 48 | catch |
---|
| 49 | pars.solver=1; |
---|
| 50 | [Y,D]=sde(Dis,3,pars); % SEDUMI |
---|
| 51 | fprintf('\n\nCSDP does not seem to be installed correctly.\n'); |
---|
| 52 | fprintf('SeDuMi is working!\n'); |
---|
| 53 | end; |
---|
| 54 | subplot(2,1,2); |
---|
| 55 | scatter(Y(1,:),Y(2,:),60,tt,'filled'); axis equal; |
---|
| 56 | title('Reduced Dimensionality'); |
---|