comparison mt_get_transmat_at.m @ 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
comparison
equal deleted inserted replaced
3:ffd7efa3e5c0 4:931e71c24aa3
1 % mt_get_transmat_at - Get transition matrix near given point in information space. 1 % mt_get_transmat_at - Get transition matrix nearest given point in information space.
2 % 2 %
3 % mt_get_transmat_at :: 3 % mt_get_transmat_at ::
4 % mt_system ~'Melody Triangle system structure', 4 % mt_system ~'Melody Triangle system structure',
5 % natural ~'voice Id (1 or greater)', 5 % natural ~'voice Id (1 or greater)',
6 % K:natural ~'size of transition matrix', 6 % K:natural ~'size of transition matrix',
8 % real ~'Y-coordinate' 8 % real ~'Y-coordinate'
9 % -> [[K,K]] ~'transition matrix', 9 % -> [[K,K]] ~'transition matrix',
10 % [[1,3]] ~'information coordinates'. 10 % [[1,3]] ~'information coordinates'.
11 % 11 %
12 % The selected transition matrix will be shown using mt_show_transmat, 12 % The selected transition matrix will be shown using mt_show_transmat,
13 % and it's information coordinates printed in the title of the main scatter plot.
14 13
15 function [T,P,I]=mt_get_transmat_at(Sys,Id,K,X,Y) 14 function [T,P,I]=mt_get_transmat_at(Sys,Id,K,X,Y)
16 logK=log(K); 15 logK=log(K);
17 normpos = Sys.map([X;Y])'; 16 normpos = Sys.map([X;Y])';
18 target = normpos*logK; 17 target = normpos*logK;
20 info = Sys.info{K}; 19 info = Sys.info{K};
21 L = size(info,1); 20 L = size(info,1);
22 21
23 % distance from target 22 % distance from target
24 d2 = sum((info(:,1:2) - repmat(target,L,1)).^2,2); 23 d2 = sum((info(:,1:2) - repmat(target,L,1)).^2,2);
25 Mask = d2<=max(min(d2)*2,0.01); 24 [dummy,J]=min(d2);
26
27 M = find(Mask);
28 % J = M(argmax(info(M,3)));
29 J = M(1+floor(length(M)*rand));
30 T = tmats(:,:,J); 25 T = tmats(:,:,J);
31 I = info(J,:); 26 I = info(J,:);
32 %Mask=2*int16(Mask); Mask(J)=1;
33 %set(Sys.hScat{K},'CDATA',Mask); % scatc(info,Mask,16); rotate3d on;
34 %figure(Sys.fig); title(sprintf('info: %.2f, %.2f, %.2f',I(1),I(2),I(3)));
35 %figure(50); title(sprintf('pos: %.2f, %.2f',normpos(1), normpos(2)));
36 %fprintf('normpos: %.2f, %.2f',normpos(1), normpos(2));
37 mt_show_transmat(Id,T,I); 27 mt_show_transmat(Id,T,I);
38 if nargin>1, P=Sys.revmap(I(1:2)'/logK); end 28 if nargin>1, P=Sys.revmap(I(1:2)'/logK); end
39 end 29 end