Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Multidimensional scaling (MDS) is a statistical technique that has been used by

ID: 3552295 • Letter: M

Question

Multidimensional scaling (MDS) is a statistical technique that has been used by cognitive scientists
to create spatial representations of the similarities among a set of stimuli. Matlab has several
commands that perform di?erent types of multidimensional scaling. In this problem we will use
nonmetric multidimensional scaling, which ?nds a spatial representation where the ordering of
distances between points in R^n corresponds to the ordering of dissimilarities among a set of stimuli.
To begin, load kinship.mat from ps03/problem1/kinship.mat using the load command. This
should load two variables into the workspace:


Explanation / Answer

% ---------------------------------
% Problem Set 3, Question 1
% ---------------------------------
%
% Author: YOUR NAME HERE
% Collaborators:
%
% ---------------------------------

%% FUNCTION DESCRIPTION
% nonMetricMDS takes as input the 1 x n cell array names and a real valued
% n x n matrix similarities and outputs sim2d, an n x 2 matrix of coordinates in 2D space
% and plot1, a structured array containing information about the kinshipPlot
% plot object you define within the function.

% Problem 1 (a)
% Compute a 2-dimensional representation of the similarities between the
% kinship terms in names and store it in the variable sim2d
%
% Problem 1 (b)
% Plot a BLUE SQUARE at the location of each of the 12 kinship terms using
% the plot command. Save this plot object to the variable kinshipPlot

% Problem 1 (c)
% Use the hold and text commands to place each kinship term next to its
% corresponding blue square in kinshipPlot

%%
function [sim2d, plot1, labels] = nonMetricMDS(names, similarities)

% ensures that kinshipPlot is fullscreen
figure('units','normalized','outerposition',[0 0 1 1]);

% Do not edit above this line!
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

% Part A
% 12 x 2 matrix of coordinates in 2D space
sim2d = mdscale(similarities,2);


% Part B
kinshipPlot = plot(sim2d(:,1),sim2d(:,2),'s',...
    'MarkerEdgeColor','b',...
    'MarkerFaceColor',[0.5,0.5,0.5]);

% Part C
hold on;
for i = 1:length(similarities),
    labels(i) = text(sim2d(i,1),sim2d(i,2),names(i));
end
%saveas(kinshipPlot,'mds1.jpg') % here you save the figure
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% Do not edit below this line!

plot1 = get(kinshipPlot);
labels = get(labels);
hold off;

end