You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: mhmm_sample.m
    path of file: ./repos/bnt/HMM
    
    the code of the file until where you have to start completion: function [obs, hidden] = mhmm_sample(T, numex, initial_prob, transmat, mu, Sigma, mixmat)
% SAMPLE_MHMM Generate random sequences from an HMM with (mixtures of) Gaussian output.
% [obs, hidden] = sample_mhmm(T, numex, initial_prob, transmat, mu, Sigma, mixmat)
%

    
function [obs, hidden] = mhmm_sample(T, numex, initial_prob, transmat, mu, Sigma, mixmat)
% SAMPLE_MHMM Generate random sequences from an HMM with (mixtures of) Gaussian output.
% [obs, hidden] = sample_mhmm(T, numex, initial_prob, transmat, mu, Sigma, mixmat)
%
% INPUTS:
% T - length of each sequence
% numex - num. sequences
% init_state_prob(i) = Pr(Q(1) = i)
% transmat(i,j) = Pr(Q(t+1)=j | Q(t)=i)
% mu(:,j,k) = mean of Y(t) given Q(t)=j, M(t)=k
% Sigma(:,:,j,k) = cov. of Y(t) given Q(t)=j, M(t)=k
% mixmat(j,k) = Pr(M(t)=k | Q(t)=j) : set to ones(Q,1) or omit if single mixture
%
% OUTPUT:
% obs(:,t,l) = observation vector at time t for sequence l
% hidden(t,l) = the hidden state at time t for sequence l

Q = length(initial_prob);
if nargin < 7, mixmat = ones(Q,1); end