annotate toolboxes/FullBNT-1.0.7/bnt/examples/dynamic/HHMM/Square/plot_square_hhmm.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function plot_square_hhmm(ev)
Daniel@0 2 % Plot the square shape implicit in the evidence.
Daniel@0 3 % ev{i,t} is the value of node i in slice t.
Daniel@0 4 % The observed node contains a velocity (delta increment), which is converted
Daniel@0 5 % into a position.
Daniel@0 6 % The Q2 node specifies which model is used, and hence which color
Daniel@0 7 % to use: 1=red, 2=green, 3=blue, 4=black.
Daniel@0 8
Daniel@0 9 Q1 = 1; Q2 = 2; Q3 = 3; F3 = 4; F2 = 5; Onode = 6;
Daniel@0 10
Daniel@0 11 delta = cell2num(ev(Onode,:)); % delta(:,t)
Daniel@0 12 Q2label = cell2num(ev(Q2,:));
Daniel@0 13
Daniel@0 14 T = size(delta, 2);
Daniel@0 15 pos = zeros(2,T+1);
Daniel@0 16 hold on
Daniel@0 17 cols = {'r', 'g', 'b', 'k'};
Daniel@0 18 for t=2:T+1
Daniel@0 19 pos(:,t) = pos(:,t-1) + delta(:,t-1);
Daniel@0 20 plot(pos(1,t), pos(2,t), sprintf('%c.', cols{Q2label(t-1)}));
Daniel@0 21 if (t==2)
Daniel@0 22 text(pos(1,t-1),pos(2,t-1),sprintf('%d',t))
Daniel@0 23 elseif (mod(t,20)==0)
Daniel@0 24 text(pos(1,t),pos(2,t),sprintf('%d',t))
Daniel@0 25 end
Daniel@0 26 end
Daniel@0 27