title: Estimate Markov Chain Transition Matrix in MATLAB With Different State Sequence Lengths
body: <p>I'm trying to build the transition matrix for a Markov Chain in MATLAB; I have several different observation sequences (all of varying lengths) and I need to generate the transition matrix using those. </p>
  
  <p><a href="https://stackoverflow.com/questions/11072206/constructing-a-multi-order-markov-chain-transition-matrix-in-matlab">Constructing a multi-order Markov chain transition matrix in Matlab</a> shows me how to build a transition matrix with a single observation sequence.</p>
  
  <p>How can I construct one using observations of different length? One example can be that one sequence is 1,2,3,4 and another is 4,5,6. Is there any way to do this without having to for loop through all sequences and computing counts?</p>