- #1
maverick280857
- 1,789
- 4
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
[tex]\dot{x} = Ax + Bu[/tex]
[tex]y = Cx[/tex]
where [itex]u = -Kx[/itex], so the system reduces to
[tex]\dot{x} = (A-BK)x[/tex]
The solution is
[tex]x(t) = exp((A-BK)t)x(0)[/tex]
I know [itex]x(0)[/itex], A, B and K and want to plot
[tex]y(t) = Cexp((A-BK)t)x(0)[/tex]
as a function of time t.
This is the code I used to compute the state transition matrix
And here is the code to compute y
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)?
Thanks in advance.
Cheers
Vivek
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
[tex]\dot{x} = Ax + Bu[/tex]
[tex]y = Cx[/tex]
where [itex]u = -Kx[/itex], so the system reduces to
[tex]\dot{x} = (A-BK)x[/tex]
The solution is
[tex]x(t) = exp((A-BK)t)x(0)[/tex]
I know [itex]x(0)[/itex], A, B and K and want to plot
[tex]y(t) = Cexp((A-BK)t)x(0)[/tex]
as a function of time t.
This is the code I used to compute the state transition matrix
Code:
function [phi] = statetrans(A)
t = sym('t');
phi = expm(A * t);
end
And here is the code to compute y
Code:
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:
>> t = 0:0.01:10;
>> plot(t,y);
? Error using ==> plot
Conversion to double from sym is not possible.
Thanks in advance.
Cheers
Vivek