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