function [a,phi,gam,c,d,q,x0,dt,rowinq,b]=ml_p2ss1(p)
 % Original parameter vector was [-1 10 1 0 2 0 .01]
rowinq=[0 0 0 0 1 0 0];
dt=p(7);  a=p(1);  b=p(2);  c=p(3);  d=p(4);  f=p(5);
q=f*sqrt(dt);%    SAME SIZE AS a
x0=p(6);%         ROW VECTOR
 %following two lines from c2d.m
[m,n] = size(a);[m,nb] = size(b);s = expm([[a b]*dt; zeros(nb,n+nb)]);
phi = s(1:n,1:n);gam = s(1:n,n+1:n+nb);
return
%---------------------------------------------------------------------------
%                      p2ss  function for ml_demo1.m
%                TESTCASE 1, Maine and Iliff,  NASA TP1690
%---------------------------------------------------------------------------
%                             DOCUMENTATION
%
%From input vector p, this function must return a,phi,gam,c,d,q,x0,dt,rowinq,b
%NOTE All program variables are LOWER CASE.
%
% Continuous state eqn :   Xdot   = a   * X     +  b * U       +  f * en
%
%       Is modeled by :   X(n+1) = phi * X(n)  +  gam * U(n)  +  q * es(n)
%                          X(0)   = x0 (row vector)
%
% The measurement equation is
%
%            Y(n)   = c * X(n)  +  d * U(n)  +  scriptgg * eta(n)
%  where
%          en   has unit spectral density.
%     es, eta   are independent unit covariance random processes.
%         q_q   is the State Noise Covariance. Note - is same size as a
%           q   chol(q_q)-- is usually assumed diagonal.
%     phi,gam   are obtained from [phi,gam]=c2d(a,b,dt)
%    scriptgg   (measurement noise covariance)-unused.  MMLE.M uses the
%               guessed or estimated innovations covariance and f.
%
%  " a " must be  returned to solve the K.F. eqns in terms of INNOVATIONS
%        covariance and state noise covariance. "b" is for convenience.
%
%  Rowinq is a vector of same dimension as p, and gives the row in q in which
%        each parameter appears, else 0.
%
%  NOTE : If q is zeros, a zero Kalman gain is used, even if 'a' is unstable
%
%  NASA TP 1690 specifies the state equations in continuous form, using f for
%        the square root of the power spectral density of the state noise.
%        The discrete equivalent is then computed as   qq' = ff' * dt.
%        MMLE.M uses q directly.  This is more convenient when simulating
%        data and estimating effects of a-d conversion noise on input data.
%--------------------------------------------------------------- end p2ssim

