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

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function plot_square_hhmm(ev)
wolffd@0 2 % Plot the square shape implicit in the evidence.
wolffd@0 3 % ev{i,t} is the value of node i in slice t.
wolffd@0 4 % The observed node contains a velocity (delta increment), which is converted
wolffd@0 5 % into a position.
wolffd@0 6 % The Q2 node specifies which model is used; each segment is color-coded
wolffd@0 7 % in the order red, green, blue, black.
wolffd@0 8
wolffd@0 9 Q1 = 1; Q2 = 2; Q3 = 3; F3 = 4; F2 = 5; Onode = 6;
wolffd@0 10
wolffd@0 11 delta = cell2num(ev(Onode,:)); % delta(:,t)
wolffd@0 12 Q2label = cell2num(ev(Q2,:));
wolffd@0 13
wolffd@0 14 T = size(delta, 2);
wolffd@0 15 pos = zeros(2,T+1);
wolffd@0 16 clf
wolffd@0 17 hold on
wolffd@0 18 cols = {'r', 'g', 'b', 'k'};
wolffd@0 19 boundary = 0;
wolffd@0 20 coli = 1;
wolffd@0 21 for t=2:T+1
wolffd@0 22 pos(:,t) = pos(:,t-1) + delta(:,t-1);
wolffd@0 23 plot(pos(1,t), pos(2,t), sprintf('%c.', cols{coli}));
wolffd@0 24 if t < T
wolffd@0 25 boundary = (Q2label(t) ~= Q2label(t-1));
wolffd@0 26 end
wolffd@0 27 if boundary
wolffd@0 28 coli = coli + 1;
wolffd@0 29 coli = mod(coli-1, length(cols)) + 1;
wolffd@0 30 end
wolffd@0 31 end
wolffd@0 32