% A script to find the nearest song to given one

% Call Pandora_Student_Matrix
	%Pandora_Student_Matrix;
	allsongs;
	S = importdata('songlist_f15.csv');

	 A = [];
	for i = 1:length(M)
	A = cat(2,A,M{i});
	end;
	
% Create a distance matrix for the given songs
	for i = 1:size(A,2)
			for j = 1:size(A,2)
					DistanceMatrix(i,j) = norm(A(:,i) - A(:,j));
			end;
	end;

% Print out the order of closeness for each song
for kk = 1:length(S)
		
	k = randi(length(S),1);
	disp(['For the song title "', S{k}, '" the most similar songs are ']) 
	D = DistanceMatrix(:,k);
	[sD,ix] = sort(D);
	Closest = S{ix(2)}
	SecondClosest = S{ix(3)}
	ThirdClosest = S{ix(4)}
	sprintf('Hit enter to continue ... \r');
	disp(' ----- @@@@ ---- @@@ --- @@ -- @ - @ -- @@ --- @@@ ---- @@@@ ----- ');
	disp(' ---- @@@@ ---- @@@ --- @@ -- @ - @ -- @@ --- @@@ ---- @@@@ ----- ');
	disp(' --- @@@@ ---- @@@ --- @@ -- @ - @ -- @@ --- @@@ ---- @@@@ ----- ');
	disp(' -  															- ');
	pause
	end

