Register to reply 
How do I numerically compute a statespace equation? 
Share this thread: 
#1
Feb711, 05:45 AM

P: 58

Suppose that, I have a linear system which is analytically defined as below:
[itex]\frac{dx}{dt} = Ax + Bu \, .......... \, (I)[/itex] [itex]y = Cx + Du \, ............ \, (II)[/itex] A, B, C, D are matrices defining the system, u is input, y is output. I want to simulate this system in computer (not by using Matlab or any other libraries/tools) by sending input values and receiving corresponding output values. How do I do this? What is the basic idea? Do I have to iterate the equation (I) by calculating dx/dt and using it to calculate the value of x, then use it in equation (II) to find the output? What is x vector for in the first place? Why do we calculate it? 


#2
Feb711, 09:04 AM

Math
Emeritus
Sci Advisor
Thanks
PF Gold
P: 39,495

Yes, you should use something like a "RungeKutta" method to solved the differential equation for x, then use it in the equation for y.
As to "what is x vector for", that would depend entirely upon the problem the system of equations is from! 


#3
Feb711, 11:24 AM

P: 58

Suppose that, input sample rate is 1 samples/second. I use RungeKutta method with a time step (h) which is very low compared to the sample rate and integer divisor of it; for example h=0.1 seconds. I receive an input sample, then apply it Runge Kutta method 10 times (10 = 1/0.1), then receive the next input and so on... In this case, can we guaranty that the accumulating error of Runge Kutta (or any other derivation method) converges? In other words, will the error remain small, or it will grow up in time? 


#4
Feb1011, 09:53 AM

P: 58

How do I numerically compute a statespace equation?
Could it be by solving it with the equation below?:
[itex]x(t) = e^{At}x(tT) + \int_{tT}^{t} e^{A(t  \tau)}Bu(\tau)d\tau[/itex] "T" is the sampling period of the input signal. To calculate the state vector between any two input samples, I will just solve this equation. Would this method work? Even if it works, the integration term requires input signal to be a continuous function; but it originally is discreet. How do I use it as a continuous function? Would interpolation with Legendre polynomials work for estimating the input signal "u "between u(tT) and u(t)? 


#5
Feb1011, 02:05 PM

PF Gold
P: 959

In order to find the "right" step size, you would in practice normally employ socalled adaptive step size control when using RungeKutta and similar methods which works by estimating and monitoring the truncation error in the numerical solution. For instance, using RK4, a popular fourthorder method, the truncation error should be proportional with h^{4} so from the same initial state you can calculate the next state using different h (say, h and h/2) and compare the normed difference in state to a set limit. If error is above limit you reduce h, if well below, you can increase h. Most ODE solver libraries implements something like this principle and allows you to specify the relative or absolute error the solver should strive to maintain. As a further example, one RK variant, called embedded RK, allows you to calculate a step from the same state using two approximations with different orders but only with a minimum of additional computational effort, making adaptive step size control particular attractive for those methods. One common example of such a method is the RungeKuttaFeldberg 7/8 (aka RKF78) method. There are plenty of good text books on the subject if you like to read more. I can personally recommend [1], although it is a bit old. There may be more appropriate reference if you are mostly interested in the statespace solution to a given control system. [1] Numerical Methods for Ordinary Differential Systems, Lambert, Wiley 1991. 


Register to reply 
Related Discussions  
Help me compute numerically this integral  Calculus  9  
Sampling from transition equation (state space model)  Set Theory, Logic, Probability, Statistics  0  
Controllability of state space equation  Engineering, Comp Sci, & Technology Homework  1  
Nonlinear differential equation to state space form  Engineering, Comp Sci, & Technology Homework  0  
State Space Differential Equation HW  Calculus & Beyond Homework  0 