Anda di halaman 1dari 3

Tutorial for using Matlab

(an introduction to relative functions needed for N1040 Linear System) Prepared by Szu-Chi Tien I. Some useful functions for control Here Ill list some functions used in this course. Simulate LTI model response to arbitrary inputs [y,t,x] = lsim(A, B, C, D, u, t, x0); or [y,t,x] = lsim(sys,u,t,x0);

Reduced row echelon form of matrix A RREF(A)

Orthonormal basis for the null space of A NULL(A)

Orthonormal basis for the range of A ORTH(A)

Rank of A RANK(A)

Sigular Value Decomposition of A [U,S,V] = SVD(A) Note: if A is a controllability matrix, the first q-column vectors in U-matrix corresponding to non-zero singular values can be used as the basis of controllable subspace; the rest column-vectors in U-matrix can be used as the basis of uncontrollable subspace. Moreover, these column vectors are orthornomal.

Find the Controllability Matrix CTRB(A,B)

Find the Observability Matrix OBSV(A,C) II. Operation with symbolic tool box Using Matlab symbolic tool box allows users to do symbolic operations. To let Matlab recognize that users want to do symbolic operation instead numerical computation, some key-things should be addressed. 1. Its a good habit to use >> clear to clear all variable in the workspace before doing the symbolic operation. This will avoid messing up usual variables and symbolic variables. 2. Use >> syms to declare a symbolic variable that users want to use for symbolic operation. 3. Use >> whos to list declared symbolic variables. 4. Use >> help sym/function_name to find how to use a symbolic function. For instance, to know how to do differentiation, use help sym/diff 5. Some examples for useful functions are listed as follows

Matrix exponential clear; syms t; A=[0 1; -1 0]; exp_At=expm(A*t);

Partial Fraction find the partial fraction expression of s +1 b( s ) r1 r2 3 2 = = + +k = + ( s + 3)( s + 4) a ( s ) s p1 s p 2 s+4 s+3 b=[1 1];| a=[1 7 12]; [r,p,k] = residue(b,a);

Inverse of Matrix clear; syms s; a=[1/s

1; 1

1/(s+1) ]; % simplify the results

a_inv=inv(a); a_inv_simple=simple(a_inv);

Determinant clear; syms s; a=[1/s a_det=det(a);

1; 1

1/(s+1) ];

Laplace/ Inverse Laplace Transform clear; syms t; F=sin(t)*exp(-t); F_la=laplace(F); F_inv_la=ilaplace(F_la);

Differentiation clear, syms a b c x; f=exp(-a*x)*x^(3*b)*sin(c*x); diff_f = diff(f,x); diff_f_simple=simple(diff_f); %simplify the result

Indefinite/ Definite Integration clear, syms a c x; g=exp(-a*x)*sin(c*x); indef_int_g = int(g,x); def_int_g=int(g,x,-pi,pi);

solution of equation clear, syms x y z a b c; eq = 'a*x^2+b*x+c = 0'; [x]=solve(eq,x);

Anda mungkin juga menyukai