How to Plot a Symbolic Function in MATLAB for Full State Feedback Problem?

  • Context: MATLAB 
  • Thread starter Thread starter maverick280857
  • Start date Start date
  • Tags Tags
    Feedback Matlab State
Click For Summary
SUMMARY

This discussion addresses plotting a symbolic function in MATLAB while solving a full state feedback problem in control theory. The user, Vivek, presents a system defined by state variables and seeks to plot the output function y(t) derived from the state transition matrix. The provided MATLAB code computes the state transition matrix and the output, but encounters an error when attempting to plot the symbolic function. The solution involves using the ezplot function to visualize the symbolic output over a specified time range.

PREREQUISITES
  • Understanding of control theory concepts, specifically full state feedback.
  • Familiarity with MATLAB programming, particularly symbolic computation.
  • Knowledge of state-space representation in control systems.
  • Experience with MATLAB plotting functions, including ezplot.
NEXT STEPS
  • Learn how to use MATLAB's ezplot for plotting symbolic expressions.
  • Explore MATLAB's symbolic toolbox for advanced symbolic computations.
  • Study state-space control design techniques, focusing on pole placement methods.
  • Investigate the use of fplot for plotting functions in MATLAB.
USEFUL FOR

Control engineers, MATLAB users, and students studying control theory who need to visualize symbolic functions in MATLAB.

maverick280857
Messages
1,774
Reaction score
5
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:
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
 
Physics news on Phys.org
Got it, can use ezplot.
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 18 ·
Replies
18
Views
4K
  • · Replies 11 ·
Replies
11
Views
3K
Replies
2
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K