0% found this document useful (0 votes)
71 views2 pages

State Space 9

This document contains MATLAB code that defines several state space models and performs various operations on them such as converting between transfer function and state space representations, computing eigenvalues, performing transformations to canonical forms, and simulating step responses. Various state space models are defined with different A, B, C, and D matrices and functions like ss(), tf2ss(), ss2tf(), step(), pzmap(), feedback(), canon() are demonstrated.

Uploaded by

machineman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views2 pages

State Space 9

This document contains MATLAB code that defines several state space models and performs various operations on them such as converting between transfer function and state space representations, computing eigenvalues, performing transformations to canonical forms, and simulating step responses. Various state space models are defined with different A, B, C, and D matrices and functions like ss(), tf2ss(), ss2tf(), step(), pzmap(), feedback(), canon() are demonstrated.

Uploaded by

machineman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

statespace9.

m
%%%% Define a state space object
A=[1 2;3 2];B=[1;0];C=[1 ‐1]; D=0;
G=ss(A,B,C,D)

A=[0 1 2;‐1 3 0;0 2 0];B=[1;0;‐2];C=[1 ‐1 0]; D=0;
G=ss(A,B,C,D)

A=[‐1 0.1;0.2 ‐0.5];B=[1;2];C=[1 0];D=0;
G=ss(A,B,C,D)
step(G)
pzmap(G)
Gc=feedback(G,1)

n=[1 2];
d=[1 4 ‐2];
[A,B,C,D]=tf2ss(n,d)

n=[‐9 0 2];
d=[1 3 2 ‐2];
[A,B,C,D]=tf2ss(n,d)

A=[1 2;3 2];B=[1;0];C=[1 ‐1]; D=0;
[n,d]=ss2tf(A,B,C,D,1)

A=[0 1 2;‐1 3 0;0 2 0];B=[1;0;‐2];C=[1 ‐1 0]; D=0;
[n,d]=ss2tf(A,B,C,D,1)

A=[‐1 0 0.2;‐1 ‐3 0;0 0.1 ‐0.5];B=[1;0;‐2];C=[1 ‐1 0]; D=0;
T=[2 1 1;0 1 ‐1; ‐3 0 2]; Ti=inv(T);
Ahat=T*A*Ti; Bhat=T*B;Chat=C*Ti;
G=ss(A,B,C,D);
Ghat=ss(Ahat,Bhat,Chat,D);
[y,t]=step(G);
[yhat]=step(Ghat,t);
plot(t,y,'r',t,yhat,'o');
eig(A)
eig(Ahat)

A=[‐1 0 0.2;‐1 ‐3 0;0 0.1 ‐0.5];
[W,lambda]=eig(A);
Ahat=inv(W)*A*W
lambda

A=[0 1 2;‐1 3 4;0 2 0];B=[1;0;‐2];C=[1 ‐1 0]; D=0;
G=ss(A,B,C,D);
[Canform,T]=canon(G,'companion')
[Canform,T]=canon(G,'modal')
Page 1
statespace9.m

Page 2

You might also like