2024年4月20日发(作者:)

1 Use MatLab to convert from state space to state space (symbolic)

2 This script requires the MatLab's symbolic toolbox

3

4 % Start by clearing everything

5 clear all

6 clc

7 format compact

8 Declare all symbolic variables

9

10 syms k1 k2 b m

11 Define state space system

12

13 A=[0 1 0; -(k1+k2)/m 0 k1/m; k1/b 0 -k1/b];

14 B=[0; 1/m; 0];

15 C=[0 0 1];

16 D=0;

17

18 Define state transformation matrix and find its inverse

19

20 T=[1/2 0 1/2; -1 0 1; 0 1 0;];

21 Tinv=inv(T)

22 Tinv =

23 1.0000 -0.5000 0

24 0 0 1.0000

25 1.0000 0.5000 0

26

27 Find new state space system

28

29 % Ahat

30 Ahat = simplify(T*A*Tinv)

31

32 % Bhat

33 Bhat = T*B

34

35 % Chat

36 Chat = C*Tinv

37

38 % Dhat

39 Dhat = D

40 Ahat =

41 [ 0, -k1/(2*b), 1/2]

42 [ 0, -k1/b, -1]

43 [ -k2/m, (2*k1 + k2)/(2*m), 0]

44 Bhat =

45 0

46 0

47 1/m

48 Chat =

49 1.0000 0.5000 0

50 Dhat =

51 0

View Code