AA=(({{0, 1, 0, 0}, {0, ((-F)/M), 0, 0}, {0, 0, 0, 1}, {((-g)/L), 0, (g/L), 0}}));BB=(({{0}, {(1/M)}, {0}, {0}}));CC1=(({{((-1)/L), 0, (1/L), 0}}));CC=(({{((-1)/L), 0, (1/L), 0}, {1, 0, 0, 0}}));DD={{0},{0}};

con=ControllabilityMatrix[StateSpaceModel[{AA,BB}]];

con //MatrixForm

MatrixRank[con]

obs1=ObservabilityMatrix[StateSpaceModel[{AA,BB,CC1}]];
obs1 //MatrixForm

MatrixRank[obs1]

sys=StateSpaceModel[{AA,BB,CC,DD}];

sys

Det[s IdentityMatrix[4] -AA] //Expand

numParam={F->1,M->1,g->1,L->2};

-((F g s)/(L M))-((g (s^2))/L)+((F (s^3))/M)+(s^4) /.numParam

Solve[-(s/2)-((s^2)/2)+(s^3)+(s^4)==0,s]

Say we want poles at locations:  -1, -2, -3, -4

(s+1)(s+2)(s+3)(s+4) //Expand

Fc = (({{(0-24), (((-1)/2)-50), (((-1)/2)-35), (1-10)}}));
Fc //MatrixForm

q=Inverse[con]//Last

PP={q,q.AA,q.AA.AA,q.AA.AA.AA};
PP //MatrixForm

FF = Fc.PP /.numParam;
FF //MatrixForm

stateOpenResponse=StateResponse[sys,1,t] /.numParam //Simplify

Plot[stateOpenResponse,{t,0,5}]

MatrixForm /@{AA+BB.FF,BB,CC+DD.FF ,DD  }

stateWithFeedbackResponse=StateResponse[StateSpaceModel[{AA+BB.FF,BB,CC+DD.FF ,DD  } /.numParam],1,t] /.numParam //Simplify

Plot[stateWithFeedbackResponse,{t,0,5}]

outputWithFeedbackResponse=OutputResponse[StateSpaceModel[{AA+BB.FF,BB,CC+DD.FF ,DD  } /.numParam],1,t] /.numParam //Simplify

out[t_]:=CC.MatrixExp[AA t]. Transpose[{{0,0,0,0}}]  (*zeros(4,1)*)+  CC.NIntegrate[MatrixExp[AA (t-s)/.numParam].BB  1,{s,0,t}] + DD 1  /.numParam  //Simplify

out[4]

Table[out[t],{t,1,5}]

outputWithOutFeedbackResponse=OutputResponse[StateSpaceModel[{AA,BB,CC ,DD  } /.numParam],1,t] /.numParam //Simplify

Table[outputWithOutFeedbackResponse //N,{t,1,5}]

Observer......

KK=(({{-2, 0.1}, {-2, 0.1}, {2, 0.1}, {2, 0.1}}));

EKmatrix=(AA-KK.CC) /.numParam;

Eigenvalues[EKmatrix]

a~f~b

Transpose[Transpose[BB-KK.DD]~Join~Transpose[KK]] //MatrixForm

observer=StateSpaceModel[{AA-KK.CC /.numParam,Transpose[Transpose[BB-KK.DD]~Join~Transpose[KK]] /.numParam,
                   
CC /.numParam}]

outputWithOutFeedbackResponse

stateNoFeedbackResponse=StateResponse[{sys,{0,0,0.25,0.1}},1,t] /.numParam //Simplify

observerEstimate=StateResponse[observer,{1}~Join~outputWithOutFeedbackResponse,{t,0,5}]

Plot[{observerEstimate[[3]],stateNoFeedbackResponse[[3]]},{t,0,10}]

?StateResponse

KK=(({{-2, 0.1}, {-2, 0.1}, {2, 0.1}, {2, 0.1}}));

Eigenvalues[AA-KK.CC /.numParam]