Question: Function transfer with direct method and state method

Hello,

I like to plot the Bode diagram of function transfer. For that purpose, i use Dynamicsystem package.

I obtain my transfer function by 2 different methods : 
- direct method
- state space method.

The issue is the fact that i don't obtain the same results with the 2 methods.

 state_space_metho.pdf
direct_method.pdf 

code of direct method;
restart;with(LinearAlgebra): with(Student[MultivariateCalculus]):with( DynamicSystems

):with(plots):M88:=Matrix(8, 8, {(1, 1) = 1, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (1, 6) = 0, (1, 7) = 0, (1, 8) = 0, (2, 1) = 0, (2, 2) = 1, (2, 3) = 0, (2, 4) = 0, (2, 5) = 0, (2, 6) = 0, (2, 7) = 0, (2, 8) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 1, (3, 4) = 0, (3, 5) = 0, (3, 6) = 0, (3, 7) = 0, (3, 8) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = 1, (4, 5) = 0, (4, 6) = 0, (4, 7) = 0, (4, 8) = 0, (5, 1) = 0, (5, 2) = 0, (5, 3) = 0, (5, 4) = 0, (5, 5) = 1, (5, 6) = 0, (5, 7) = 0, (5, 8) = 0, (6, 1) = 0, (6, 2) = 0, (6, 3) = 0, (6, 4) = 0, (6, 5) = 0, (6, 6) = 1, (6, 7) = 0, (6, 8) = 0, (7, 1) = 0, (7, 2) = 0, (7, 3) = 0, (7, 4) = 0, (7, 5) = 0, (7, 6) = 0, (7, 7) = 1, (7, 8) = 0, (8, 1) = 0, (8, 2) = 0, (8, 3) = 0, (8, 4) = 0, (8, 5) = 0, (8, 6) = 0, (8, 7) = 0, (8, 8) = 1});K88:=Matrix(8, 8, {(1, 1) = 2000000, (1, 2) = 0, (1, 3) = 0., (1, 4) = -1000000, (1, 5) = 0, (1, 6) = -99256.35650, (1, 7) = 0, (1, 8) = 0, (2, 1) = 0, (2, 2) = 2000000, (2, 3) = 0., (2, 4) = 0, (2, 5) = -1000000, (2, 6) = 490049.1564, (2, 7) = 0, (2, 8) = 0, (3, 1) = 0., (3, 2) = 0., (3, 3) = 19927.59766, (3, 4) = -100000.0000, (3, 5) = 0.2051033808e-4, (3, 6) = -9925.635660, (3, 7) = 0, (3, 8) = 0, (4, 1) = -1000000, (4, 2) = 0, (4, 3) = -100000.0000, (4, 4) = 2000000, (4, 5) = 0, (4, 6) = 0., (4, 7) = -1000000, (4, 8) = 0, (5, 1) = 0, (5, 2) = -1000000, (5, 3) = 0.2051033808e-4, (5, 4) = 0, (5, 5) = 2000000, (5, 6) = 0., (5, 7) = 0, (5, 8) = -1000000, (6, 1) = -99256.35650, (6, 2) = 490049.1564, (6, 3) = -9925.635660, (6, 4) = 0., (6, 5) = 0., (6, 6) = 500073.8114, (6, 7) = 99256.35650, (6, 8) = -490049.1564, (7, 1) = 0, (7, 2) = 0, (7, 3) = 0, (7, 4) = -1000000, (7, 5) = 0, (7, 6) = 99256.35650, (7, 7) = 1000000, (7, 8) = 0, (8, 1) = 0, (8, 2) = 0, (8, 3) = 0, (8, 4) = 0, (8, 5) = -1000000, (8, 6) = -490049.1564, (8, 7) = 0, (8, 8) = 2000000});DDD:=(M88*s^2+K88);TTT:=MatrixInverse(DDD):> TTT:=TransferFunction();PrintSystem(TTT);MagnitudePlot(TTT,linearfreq=true,linearmag = true, decibels = false,hertz = true, range = .01 .. 100,view=[.01 .. 100,0 .. 0.0001]);


Code of state space method:

restart;with(linalg):with(LinearAlgebra): with(Student[MultivariateCalculus]):with( DynamicSystems ):with(plots):M88:=Matrix(8, 8, {(1, 1) = 1, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (1, 6) = 0, (1, 7) = 0, (1, 8) = 0, (2, 1) = 0, (2, 2) = 1, (2, 3) = 0, (2, 4) = 0, (2, 5) = 0, (2, 6) = 0, (2, 7) = 0, (2, 8) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 1, (3, 4) = 0, (3, 5) = 0, (3, 6) = 0, (3, 7) = 0, (3, 8) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = 1, (4, 5) = 0, (4, 6) = 0, (4, 7) = 0, (4, 8) = 0, (5, 1) = 0, (5, 2) = 0, (5, 3) = 0, (5, 4) = 0, (5, 5) = 1, (5, 6) = 0, (5, 7) = 0, (5, 8) = 0, (6, 1) = 0, (6, 2) = 0, (6, 3) = 0, (6, 4) = 0, (6, 5) = 0, (6, 6) = 1, (6, 7) = 0, (6, 8) = 0, (7, 1) = 0, (7, 2) = 0, (7, 3) = 0, (7, 4) = 0, (7, 5) = 0, (7, 6) = 0, (7, 7) = 1, (7, 8) = 0, (8, 1) = 0, (8, 2) = 0, (8, 3) = 0, (8, 4) = 0, (8, 5) = 0, (8, 6) = 0, (8, 7) = 0, (8, 8) = 1});> K88:=Matrix(8, 8, {(1, 1) = 2000000, (1, 2) = 0, (1, 3) = 0., (1, 4) = -1000000, (1, 5) = 0, (1, 6) = -99256.35650, (1, 7) = 0, (1, 8) = 0, (2, 1) = 0, (2, 2) = 2000000, (2, 3) = 0., (2, 4) = 0, (2, 5) = -1000000, (2, 6) = 490049.1564, (2, 7) = 0, (2, 8) = 0, (3, 1) = 0., (3, 2) = 0., (3, 3) = 19927.59766, (3, 4) = -100000.0000, (3, 5) = 0.2051033808e-4, (3, 6) = -9925.635660, (3, 7) = 0, (3, 8) = 0, (4, 1) = -1000000, (4, 2) = 0, (4, 3) = -100000.0000, (4, 4) = 2000000, (4, 5) = 0, (4, 6) = 0., (4, 7) = -1000000, (4, 8) = 0, (5, 1) = 0, (5, 2) = -1000000, (5, 3) = 0.2051033808e-4, (5, 4) = 0, (5, 5) = 2000000, (5, 6) = 0., (5, 7) = 0, (5, 8) = -1000000, (6, 1) = -99256.35650, (6, 2) = 490049.1564, (6, 3) = -9925.635660, (6, 4) = 0., (6, 5) = 0., (6, 6) = 500073.8114, (6, 7) = 99256.35650, (6, 8) = -490049.1564, (7, 1) = 0, (7, 2) = 0, (7, 3) = 0, (7, 4) = -1000000, (7, 5) = 0, (7, 6) = 99256.35650, (7, 7) = 1000000, (7, 8) = 0, (8, 1) = 0, (8, 2) = 0, (8, 3) = 0, (8, 4) = 0, (8, 5) = -1000000, (8, 6) = -490049.1564, (8, 7) = 0, (8, 8) = 2000000});DD:=-MatrixMatrixMultiply(MatrixInverse(M88),K88);A:=blockmatrix(2,2,[ZeroMatrix(8),IdentityMatrix(8),DD,ZeroMatrix(8)]);A:=convert(A,Matrix);
B:=blockmatrix(2,1,[Vector(<0,0,0,0,0,0,0,0>),MatrixVectorMultiply(MatrixInverse(M88),Vector(<0,0,0,0,0,0,1,0>))]);B:=convert(B,Matrix);C:=blockmatrix(1,2,[IdentityMatrix(8),ZeroMatrix(8)]);C:=convert(C,Matrix);De:=Vector(<0,0,0,0,0,0,0,0>);sys := StateSpace(A,B,C,De):> PrintSystem(sys);TT:=TransferFunction(sys);PrintSystem(TT);MagnitudePlot(TT,linearfreq=true,linearmag = true,decibels = false,hertz = true,range = 0 .. 100,view=[0 .. 100,0 .. 0.0001]);#,range = 300 .. 1000,view=[300 .. 1000,0 .. 0.0001] 


With the direct method, only curve is done and i expect 8 curves.

I you don't manage to use my codes with pdf files, i can copy you the code on the post.


Thank you for help.

Please Wait...