changeset 4:931e71c24aa3

Old mt_get_transmat_at is now mt_get_transmat_near; new mt_get_transmat_at gets nearest transmat deterministically.
author samer
date Sun, 05 Feb 2012 13:34:02 +0000
parents ffd7efa3e5c0
children 80e9103b057f
files mt_get_transmat_at.m mt_get_transmat_near.m
diffstat 2 files changed, 41 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mt_get_transmat_at.m	Fri Feb 03 18:08:07 2012 +0000
+++ b/mt_get_transmat_at.m	Sun Feb 05 13:34:02 2012 +0000
@@ -1,4 +1,4 @@
-% mt_get_transmat_at - Get transition matrix near given point in information space.
+% mt_get_transmat_at - Get transition matrix nearest given point in information space.
 %
 % mt_get_transmat_at ::
 %    mt_system ~'Melody Triangle system structure',
@@ -10,7 +10,6 @@
 %    [[1,3]]   ~'information coordinates'.
 %
 % The selected transition matrix will be shown using mt_show_transmat,
-% and it's information coordinates printed in the title of the main scatter plot.
 
 function [T,P,I]=mt_get_transmat_at(Sys,Id,K,X,Y)
 	logK=log(K);
@@ -22,18 +21,9 @@
 
 	% distance from target
 	d2 = sum((info(:,1:2) - repmat(target,L,1)).^2,2);
-	Mask = d2<=max(min(d2)*2,0.01);
-
-	M = find(Mask);
-%	J = M(argmax(info(M,3)));
-	J = M(1+floor(length(M)*rand));
+	[dummy,J]=min(d2);
 	T = tmats(:,:,J);
 	I = info(J,:);
-	%Mask=2*int16(Mask); Mask(J)=1;
-	%set(Sys.hScat{K},'CDATA',Mask); % scatc(info,Mask,16); rotate3d on;
-	%figure(Sys.fig); title(sprintf('info: %.2f, %.2f, %.2f',I(1),I(2),I(3)));
-	%figure(50); title(sprintf('pos: %.2f, %.2f',normpos(1), normpos(2)));
-	%fprintf('normpos: %.2f, %.2f',normpos(1), normpos(2));
 	mt_show_transmat(Id,T,I);
 	if nargin>1, P=Sys.revmap(I(1:2)'/logK); end
 end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mt_get_transmat_near.m	Sun Feb 05 13:34:02 2012 +0000
@@ -0,0 +1,39 @@
+% mt_get_transmat_near - Get transition matrix near given point in information space.
+%
+% mt_get_transmat_near ::
+%    mt_system ~'Melody Triangle system structure',
+%    natural   ~'voice Id (1 or greater)',
+%    K:natural ~'size of transition matrix',
+%    real      ~'X-coordinate',
+%    real      ~'Y-coordinate'
+% -> [[K,K]]   ~'transition matrix',
+%    [[1,3]]   ~'information coordinates'.
+%
+% A transition matrix will be chosen at random from amongst the ones
+% within a certain radius of the target point.
+% The selected transition matrix will be shown using mt_show_transmat,
+
+
+function [T,P,I]=mt_get_transmat_at(Sys,Id,K,X,Y)
+	logK=log(K);
+	normpos = Sys.map([X;Y])';
+	target = normpos*logK;
+	tmats = Sys.transmats{K};
+	info = Sys.info{K};
+	L = size(info,1);
+
+	% distance from target
+	d2 = sum((info(:,1:2) - repmat(target,L,1)).^2,2);
+	Mask = d2<=max(min(d2)*2,0.01);
+
+	M = find(Mask);
+%	J = M(argmax(info(M,3)));
+	J = M(1+floor(length(M)*rand));
+	T = tmats(:,:,J);
+	I = info(J,:);
+	%Mask=2*int16(Mask); Mask(J)=1;
+	%set(Sys.hScat{K},'CDATA',Mask); % scatc(info,Mask,16); rotate3d on;
+	%figure(50); title(sprintf('pos: %.2f, %.2f',normpos(1), normpos(2)));
+	mt_show_transmat(Id,T,I);
+	if nargin>1, P=Sys.revmap(I(1:2)'/logK); end
+end