% load the data
load food.mat

% first, make sure that we have the som-toolbox version 2
if exist('som_use_vs2')==2
  som_use_vs2;
end

% Now you have the data in structure sD.
% Normalize it and train the som
sDN = som_normalize(sD,'var');
sMN = som_make(sDN);
figure(1)
som_show(sMN, 'norm', 'd');


%% Create your own code to visualize the created SOM
% use, depending on your student number as stated in the instructions,
% either 
% 1) princomp to create a PCA-projection (Principal Component
% Analysis). Visualize the SOM and the data using the first three
% principal componets
% 2) sammon to create a sammon's projection or 
% 3) cca to create the cca projection.

% The SOM element locations are found sMN.codebook.
% The data can be read from sDN.data 

%% This is a little colouring to help you with the colors for the 
%% grid, this aids visualization greatly (assuming that the
% projections are in SCORE - rename it as you see fit)
colors = (0:1/(size(SCORE,1)-1):1)';
figure(2)
clf

%% use som_grid to visualize the map grid
% the argument ID  'Coord' allows you to set the element locations
% the argument ID 'Surf' allows you to define the sufrace colors

% use the 'hold on' command to keep the grid plotted above
% you can use the plot3 command to print data

% the following wil print you the same SOM to allow you compare the 
% colours with with surface created above
figure(3)
som_show(sMN, 'Color', colors);
       



