Created
June 29, 2022 07:22
-
-
Save Remi-Gau/d9bc15a075fa65c6469680208976067a to your computer and use it in GitHub Desktop.
multidimensional scaling example in matlab
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
X = [ normrnd(0,1,10,3) normrnd(0,.1,10,1) ]; % generate data | |
D = pdist(X, 'euclidean'); % compute euclidiant distance | |
% do multidimensional scaling | |
% find a configuration with those inter-point distances | |
% If the first k elements of E are much larger than the remaining (n-k), then you | |
% can use the first k columns of Y as k-dimensional points, whose interpoint | |
% distances approximate D. This can provide a useful dimension reduction for | |
% visualization, e.g., for k==2. | |
[Y, e] = cmdscale(D); | |
scatter(Y(:,1), Y(:,2)) | |
xlabel('dimension 1') | |
ylabel('dimension 2') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment