The simulation runs in the order of e-8 seconds for a model containing a transfer function of 7th order in Simulink R2021a. If the simulation step-size is increased manually the simulation fails due to singularity in the transfer function.
In the case of Higher Order Transfer Functions, the solver will choose a small step-size to properly capture the high-frequency dynamics resulting from Higher Order Transfer Function. By setting the step-size manually it is prone to error because of the large variation between two successive steps.
These are the possible workarounds if simulation speed needs to be increased-
- Using Accelerator or Rapid-Accelerator Mode of Simulation if the accuracy is not to be reduced.
- If there are more simulations, they could be simulated parallelly using "parsim" function.
- If a reduction in accuracy of the simulation is acceptable "modred" function can be used to convert the transfer function to state-space model by removing negligible states.
The following code snippet provides an example of converting the transfer function to state-space model.
num = [ 3 0 ];
den = [ 2e-34 14e-25 1e-16 2e-09 0.0023 39.1 2.05e07];
sys = tf(num,den)
[sys,g] = balreal(sys)
elim = (g<1e-8)
rsys = modred(sys,elim)
For more information on the functions used in the above code snippet please refer to the following documentation links
- "modred" - https://www.mathworks.com/help/releases/R2021a/control/ref/ss.modred.html
- "tf" - https://www.mathworks.com/help/releases/R2021a/control/ref/tf.html
- "parsim" -https://www.mathworks.com/help/releases/R2021a/simulink/slref/parsim.html