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

In summary, the conversation is about a MATLAB problem related to solving a full state feedback problem in control theory. The person has a system in state variable form and wants to plot a function of time using provided codes. However, there is an error due to the use of a symbolic function and the person is seeking help to resolve it.
  • #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

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
  • #2
Got it, can use ezplot.
 
  • #3


Hi Vivek,

Thank you for sharing your MATLAB problem with us. It seems like you have already made good progress in solving the full state feedback problem in control theory. The issue you are facing is that y is a symbolic function and cannot be plotted directly. To plot y as a function of time, you will need to use the "subs" function in MATLAB to substitute the symbolic t with a numerical value from your desired range. Here is an example of how you can do this:

t = 0:0.01:10; % create a range of time values
y_numeric = subs(y, t, t(1)); % substitute t with the first value in the range
plot(t, y_numeric); % plot the numerical values of y against t

You can then repeat this process for each value in the time range to get a plot of y vs. t. I hope this helps you solve your problem. Good luck!

Best,
 

1. What is full state feedback in MATLAB?

Full state feedback in MATLAB is a control system technique used to design a controller that can independently control each state variable of a dynamic system. It involves using a state-space representation of the system and designing a feedback controller to manipulate the system's states to achieve a desired response.

2. How is full state feedback implemented in MATLAB?

In MATLAB, full state feedback can be implemented using the acker or place functions. These functions calculate the feedback gains based on the desired closed-loop poles of the system. The gains can then be used to form the feedback controller and simulate the system's response.

3. What are the advantages of using full state feedback in MATLAB?

There are several advantages to using full state feedback in MATLAB. It allows for independent control of each state variable, making it more versatile than other control techniques. It also provides the ability to achieve faster response times and better disturbance rejection. Additionally, full state feedback can be easily implemented in real-time systems.

4. What are the limitations of using full state feedback in MATLAB?

While full state feedback has many advantages, it also has some limitations. One of the main limitations is that it requires complete knowledge of the system's state variables, which may not always be available. It also does not take into account any uncertainties or disturbances in the system, which can affect the performance of the controller.

5. Can full state feedback be used for nonlinear systems in MATLAB?

Yes, full state feedback can be used for nonlinear systems in MATLAB by linearizing the system around a desired operating point. This involves approximating the nonlinear system with a linear one and then using the techniques mentioned above to design a feedback controller. However, the performance of the controller may be limited due to the linearization process.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
997
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
939
  • MATLAB, Maple, Mathematica, LaTeX
Replies
18
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
Back
Top