(y, t, x) = DiscreteTransferFunction.Analysis.timeResponse(dtf, tSpan, responseType, x0)
First, the discrete transfer function representation is transformed into a discrete state space representation which is given to DiscreteStateSpace.Analysis.timeResponse and the time response of the state space system is calculated. The type of the time response is defined by the input responseType, i.e.
Impulse "Impulse response", Step "Step response", Ramp "Ramp response", Initial "Initial condition response"
The outputs y and x are calculated from the system equations of the discrete state space system for each time step t=k*dt.
DiscreteTransferFunction z = Modelica_LinearSystems2.DiscreteTransferFunction.z(); Modelica_LinearSystems2.DiscreteTransferFunction dtf=(0.0023753*z^2 + 0.00475059*z + 0.0023753)/(z^2 - 1.89549*z + 0.904988); Real tSpan= 0.4; Modelica_LinearSystems2.Types.TimeResponse response=Modelica_LinearSystems2.Types.TimeResponse.Step; Real x0[1]={0,0}; Real y[5,1,1]; Real t[5]; Real x[5,1,1] algorithm dtf.Ts:=0.1; (y,t,x):=Modelica_LinearSystems2.DiscreteTransferFunction.Analysis.timeResponse(dtf,tSpan,response,x0); // y[:,1,1] = {0.00237529691211404, 0.0116282350020595, 0.0293927396867651, 0.0546913271597482, 0.0865678034508828} // t = {0, 0.1, 0.2, 0.3, 0.4} // x[:,1,1] = {0.0, 0.0, 1.0, 2.89548693586698, 5.58336953639396}
encapsulated function timeResponse import Modelica_LinearSystems2; import Modelica_LinearSystems2.DiscreteStateSpace; import Modelica_LinearSystems2.DiscreteTransferFunction; import Modelica_LinearSystems2.Utilities.Types.TimeResponse; extends Modelica_LinearSystems2.Internal.timeResponseMask_tf_discrete; input TimeResponse response = TimeResponse.Step; input Real x0[DiscreteTransferFunction.Analysis.denominatorDegree(dtf)] = zeros(DiscreteTransferFunction.Analysis.denominatorDegree(dtf)) "Initial state vector"; end timeResponse;