The normal "state space" and "discrete state-space" block in Simulink have different results

25 views (last 30 days)
Hello,
im simulating a system using a state-space model. The system is modelled 1.) with "State-Space" block and 2.) with a "Discrete State-Space" block. Both blocks have the same inputs as you can see in the screenshot.
Also, the matrices are the same, see screenshot below.
Both blocks are simulated in the same simulink model. However, the results show huge differences in the quantity "V_R0_Continous" and "V_R0_Discrete", see screenshot.
I´m not sure whats the problem.
Also: V_R1 is equal to the state x of the state-space model. The simulation step size is fixed at 1e-6.

Accepted Answer

Paul
Paul on 24 Oct 2023
Hi Christian,
If the simulation step size is fixed at 1e-6, then the inherited Sample Time of the Discrete State Space block is T = 1e-6. With that sample time, or any other sample time for that matter that's small enough (which 1e-6 should be for this problem), you need to compute the discretized approximation to the continuous-time state space model and use the state space matrices of the discretized approximation in the Discrete State Space block.
The function c2d offers several options for discretizing continuous time state space model for numeric models. But it looks like you want to make the block parameters variables. For this simple problem it may be sufficient to proceed as follows.
Let Ac, Bc, Cc, Dc, be the continous time state space model matrices. Then the state space matrices for the discretized model would be
Ad = I + Ac*T (I is the identity matrix compatible with A)
Bd = Bd*T
Cd = Cc
Dd = Dc
You may want to consider specifying T as workspace variable, enter T as the sample time in the DSS block, and set the solver step size to 'auto' so that you can change T if you want at some later time.

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!