Using expm of matlab to plot state responses

In summary, the conversation is about using the state space model of a nonlinear system in Matlab to find the zero input response at a specific equilibrium point with initial states and plotting the state responses using the expm function. The use of the expm function is questioned and the importance of understanding matrix exponentials for solving systems of ODEs is mentioned.
  • #1
shuh
9
0

Homework Statement


The state space model of a nonlinear system is [tex]x'_1(t) = 2x^2_2(t) - 50[/tex] [tex]x'_2(t) = -x_1(t) - 3x_2(t) + u(t)[/tex] where x_1(t) and x_2(t) are the states, and u(t) is the input. The output of the system is x_2(t).

Find the zero input response (u(t) = 0) of this system linearized at the equilibrium point (-15, 5) with initial states (-14.5, 5). Use Matlab (expm.m) to plot these state responses from 0 to 5s.

Homework Equations



State Space Modeling, Matlab

The Attempt at a Solution



The bold part is where I have an issue with this problem. Generally, if you want to find response to initial conditions, you use initial function, not expm. Expm simply takes a matrix and exponentiates it.

Anyways, MATLAB code for generating response to initial condition is:

//State Matrix
A = [ 0 20 ; -1 -3]
B = [0 ; 1]
C = [0 1]
D = 0
x0 = [ -14.5 ; 5]

sys = ss(A,B,C,d)
initial(sys, x0)

And you get a beautiful plot looking like the following:

image.png


How, and especially why on Earth would you use expm function to generate such plot?
 
Physics news on Phys.org
  • #2
Do you know what a matrix exponential is, and how it can be used to solve a system of linear, constant coefficient first order equations? If not, then either look in your textbook or google it. Even the Wikipedia page on the matrix exponential has some applications that should help here.

Why would you do this? Because it will give you an idea of one way to solve such a system of ODEs analytically. Numerically, I do not know what the 'initial' command in MATLAB does (might just numerically integrate the equations - probably doesn't do the matrix exponential). I would think that anyone who learns about state space analysis should learn about matrix exponentials at some point. Perhaps that is the real reason 'why' you would do this - so you learn more than just how to use a few Matlab commands.

enjoy,

jason
 

FAQ: Using expm of matlab to plot state responses

What is the purpose of using expm of Matlab for plotting state responses?

The expm function in Matlab is used to calculate the matrix exponential, which is a fundamental tool in solving many linear systems and differential equations. By using expm, we can plot the state responses of a system, which is a graphical representation of how the system's states change over time.

How do I use expm in Matlab to plot state responses?

To use expm for plotting state responses, you first need to define the state matrices of your system. Then, you can use the expm function to calculate the matrix exponential of these matrices. Finally, you can use the plot function to plot the state responses over time.

What are the advantages of using expm in Matlab for plotting state responses?

One of the main advantages of using expm for plotting state responses is that it is a fast and efficient tool for solving linear systems and differential equations. Additionally, it allows for easy visualization of the state responses, which can aid in understanding the behavior of the system.

Can I customize the plot of state responses using expm in Matlab?

Yes, you can customize the plot of state responses by using different plotting functions, such as plot, plot3, or stem. You can also change the color, style, and labels of the plot to make it more visually appealing and informative.

Are there any limitations to using expm in Matlab for plotting state responses?

One limitation of using expm for plotting state responses is that it is only suitable for linear systems. It may not be accurate for non-linear systems, and other methods such as numerical integration may be more appropriate. Additionally, the accuracy of the plot may be affected by the step size used in the calculation of the matrix exponential.

Similar threads

Replies
10
Views
2K
Replies
1
Views
1K
Replies
1
Views
3K
Replies
6
Views
1K
Replies
1
Views
2K
Replies
3
Views
2K
Back
Top