Main Content


Controllability and observability Gramians


Wc = gram(sys,'c')
Wc = gram(sys,'o')
Wc = gram(___,opt)


Wc = gram(sys,'c') calculates the controllability Gramian of the state-space (ss) model sys.

Wc = gram(sys,'o') calculates the observability Gramian of the ss model sys.

Wc = gram(___,opt) calculates time-limited or frequency-limited Gramians. opt is an option set that specifies time or frequency intervals for the computation. Create opt using the gramOptions command.

You can use Gramians to study the controllability and observability properties of state-space models and for model reduction [1]. They have better numerical properties than the controllability and observability matrices formed by ctrb and obsv.

Given the continuous-time state-space model


the controllability Gramian is defined by


The controllability Gramian is positive definite if and only if (A, B) is controllable.

The observability Gramian is defined by


The observability Gramian is positive definite if and only if (A, C) is observable.

The discrete-time counterparts of the controllability and observability Gramians are



Use time-limited or frequency-limited Gramians to examine the controllability or observability of states within particular time or frequency intervals. The definition of these Gramians is as described in [2].


Compute Frequency-Limited Gramian

Compute the controllability Gramian of the following state-space model. Focus the computation on the frequency interval with the most energy.

sys = ss([-.1 -1;1 0],[1;0],[0 1],0);

The model contains a peak at 1 rad/s. Use gramOptions to specify an interval around that frequency.

opt = gramOptions('FreqIntervals',[0.8 1.2]);
gc = gram(sys,'c',opt)
gc = 2×2

    4.2132   -0.0000
   -0.0000    4.2433


The A matrix must be stable (all eigenvalues have negative real part in continuous time, and magnitude strictly less than one in discrete time).


The controllability Gramian Wc is obtained by solving the continuous-time Lyapunov equation


or its discrete-time counterpart


Similarly, the observability Gramian Wo solves the Lyapunov equation


in continuous time, and the Lyapunov equation


in discrete time.

The computation of time-limited and frequency-limited Gramians is as described in [2].


[1] Kailath, T., Linear Systems, Prentice-Hall, 1980.

[2] Gawronski, W. and J.N. Juang. “Model Reduction in Limited Time and Frequency Intervals.” International Journal of Systems Science. Vol. 21, Number 2, 1990, pp. 349–376.

Version History

Introduced before R2006a