samer@0: % mt_get_transmat_at - Get transition matrix near given point in information space. samer@0: % samer@0: % mt_get_transmat_at :: samer@0: % mt_system ~'Melody Triangle system structure', samer@0: % natural ~'voice Id (1 or greater)', samer@0: % K:natural ~'size of transition matrix', samer@0: % real ~'X-coordinate', samer@0: % real ~'Y-coordinate' samer@0: % -> [[K,K]] ~'transition matrix', samer@0: % [[1,3]] ~'information coordinates'. samer@0: % samer@0: % The selected transition matrix will be shown using mt_show_transmat, samer@0: % and it's information coordinates printed in the title of the main scatter plot. samer@0: samer@0: function [T,I]=mt_get_transmat_at(Sys,Id,K,X,Y) samer@0: normpos = Sys.map([X;Y])'; samer@0: target = normpos *log(K); samer@0: tmats = Sys.transmats{K}; samer@0: info = Sys.info{K}; samer@0: L = size(info,1); samer@0: samer@0: % distance from target samer@0: d2 = sum((info(:,1:2) - repmat(target,L,1)).^2,2); samer@0: Mask = d2<=max(min(d2)*2,0.01); samer@0: samer@0: M = find(Mask); samer@0: % J = M(argmax(info(M,3))); samer@0: J = M(1+floor(length(M)*rand)); samer@0: T = tmats(:,:,J); samer@0: I = info(J,:); samer@0: %Mask=2*int16(Mask); Mask(J)=1; samer@0: %set(Sys.hScat{K},'CDATA',Mask); % scatc(info,Mask,16); rotate3d on; samer@0: figure(Sys.fig); title(sprintf('info: %.2f, %.2f, %.2f',I(1),I(2),I(3))); samer@0: %figure(50); title(sprintf('pos: %.2f, %.2f',normpos(1), normpos(2))); samer@0: %fprintf('normpos: %.2f, %.2f',normpos(1), normpos(2)); samer@0: mt_show_transmat(Id,T); samer@0: end