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