% mt_show_transmat - Display image of transition matrix for voice
%
% mt_show_transmat ::
%    natural ~'voice id'
%    [[K,K]] ~'transition matrix'
% -> action void.
%
% Also displays global information measures in bits in the title.

function mt_show_transmat(Id,T,I)
	figure(Id); 
	imagesc(T,[0,1]); 
	axis xy;
	if nargin<3, I=mc_global_info(T); end
	I=I/log(2); % convert to bits
	htit=title(sprintf('H=%.2f, R=%.2f, PI=%.2f',I(1),I(2),I(3)));
	addkbcallback(gcf);
	addkbcallback(gcf,@(k)show_eigs(Id,T));
	set(htit,'ButtonDownFcn',@(a,b)show_eigs(Id,T));
end

function show_eigs(Id,T) 
	figure(40);
	[V,D]=eig(T); d=diag(D);
	k=find(abs(d-1)<0.001);
	subplot(3,1,1); plot_cvec(diag(D)); 
	title(sprintf('%d: eigenvalues %s',Id,mat2str(d(k))));
	subplot(3,1,2); plot_cvec(sum(V)); title('sum eigenvectors');%ylim([-1,1]);
	subplot(3,1,3); plotseq(@plot_cvec,window(V)); title('eigenvector');
end
