Mercurial > octave
view scripts/control/c2d.m @ 203:5652a6bca14c
[project @ 1993-11-08 21:56:05 by jwe]
Initial revision
author | jwe |
---|---|
date | Mon, 08 Nov 1993 21:56:05 +0000 |
parents | |
children | 16a24e76d6e0 |
line wrap: on
line source
function [Ad, Bd] = c2d (Ac, Bc, T) # Usage: [Ad, Bd] = c2d (Ac, Bc, T) # # converts the continuous time system described by: # . # x = Ac x + Bc u # # into a discrete time equivalent model via the matrix exponential # # x[n+1] = Ad x[n] + Bd u[n] # # assuming a zero-order hold on the input and sample time T. # Written by R.B. Tenison (btenison@eng.auburn.edu) # October 1993 # check args if (nargin != 3) error ("usage: c2d (Ac, Bc, T)"); endif [ma, na] = size (Ac); [mb, nb] = size (Bc); if (ma != na) error ("c2d: Ac must be square"); endif if (ma != mb) error ("c2d: Ac and Bc must have the same number of rows"); endif matexp = expm ([[Ac, Bc] * T; zeros (nb, na+nb)]); Ad = matexp (1:na, 1:na); Bd = matexp (1:na, na+1:na+nb); endfunction