% This program simulates the observed states of an HMM model % given the following input: % OS = Observed states (string), % E = Emission probabilities for the observed states (matrix) % Pi = Sequence of hidden states (vector) % n = number of steps in the chain, minus one = length(Pi)-1 function X = obssim(Pi,E) n = length(Pi); X = zeros(1,n); for i = 1:n, X(i) = rando(E(Pi(i),:)); end;