Skip to content
Math Solves Everything

MATLAB: Lsim closed controlled loop confusion

closed loop full feedbackcontrollerlsim

Hey, I am a bit confused regarding lsim inputs. I wish to simulate a closed loop feedback full state controller
I am using 'space state' dynamic representation
and calculated K value to ensure Controllability
basically:
x'=Ax+Bu , y=Cx
u=-Kx
when defining the ss model:
sys_cl = ss(A-B*K,B,C,0);
but for the lsim function I need to define an already known input vector u to satisfy:
lsim(sys_cl,u,t,x0);
So on one hand I wish "u" to be defined as -Kx (adjust itself depending on the output).
on the other hand – I define a pre-known u value for the simulation
what am I missing…?

Best Answer

Hi Daniel Grebler,
In order to simulate the time response of your controlled system you need to define the system ( sys_cl), a time grid ( t ), and a target value ( u ). You define an initial state of your system by supplying ( x0 ).
See first example in Matlab documentation:
https://de.mathworks.com/help/control/ref/lsim.html?s_tid=doc_ta
Kind regards,
Robert
Related Question
  • Problem in designing state feedback controller
  • Solving a 2 input, 2output, 4state model
  • How to take feedback from a state for a MIMO design