# Full State Feedback in MATLAB

1. Aug 16, 2008

### maverick280857

Hi everyone,

I have a small MATLAB problem which arose while trying to solve a full state feedback problem in control theory.

I have a system in state variable form

$$\dot{x} = Ax + Bu$$
$$y = Cx$$

where $u = -Kx$, so the system reduces to

$$\dot{x} = (A-BK)x$$

The solution is

$$x(t) = exp((A-BK)t)x(0)$$

I know $x(0)$, A, B and K and want to plot

$$y(t) = Cexp((A-BK)t)x(0)$$

as a function of time t.

This is the code I used to compute the state transition matrix

Code (Text):

function [phi] = statetrans(A)
t = sym('t');
phi = expm(A * t);
end

And here is the code to compute y

Code (Text):

A = [0, 1, 0, 0;4.4537,0,0,0;0,0,0,1;-0.5809,0,0,0];
B = [0;-0.3947;0;0.9211];
C = [0,0,1,0];
K = place(A,B,[-3,-2,-2+j,-2-j]); % this is used to determine the feedback gain after placing closed loop zeros at the desired location

x0 = [0.01;0.01;0.1;0.1]; % initial state

% The real code starts below
phi = statetrans((A-B*K));
x   = phi*x0;
y   = C*x;

The problem is that y is a symbolic function of t. How can I plot y as a function of t for t in some range (using something like t = 0:0.01:10)?

Code (Text):

>> t = 0:0.01:10;
>> plot(t,y);
??? Error using ==> plot
Conversion to double from sym is not possible.