Please Help me solve 1.1 in MATLAB code, just as the instructions ask. Again, th
ID: 2082791 • Letter: P
Question
Please Help me solve 1.1 in MATLAB code, just as the instructions ask. Again, this is matlab question.
Consider the second-order llR filter: bo b12 b22 H(z) 3 (1) 1 a12 a22 The time domain operation of this filter can be structured in different ways corresponding to different block- diagram realizations. See for example Figures 8.13 and 8.14 of the text. In the Direct Form I realization, the calculation of the output signal y[n] from the input signal zIn] is implemented by the difference equation: (2) Assuming zero initial conditions, a[-1 -2 E y[-1] 3 y -2 0, the first two output samples are computed by (3) Afterward, (2) can be iterated for n 2. Another realization is the transposed (of the Direct Form II) realization, which is used internally by the MATLAB function filter, and is based on the system of difference equations, for n 20, azyln], (4) vi[n] and v2In] are internal state-variables. Note that (4) is usually initialized at v101 v2[0] 0 where The built-in function filter also keeps track of a similar internal state-variable vector and its more general usage is as follows:Explanation / Answer
The following setup method from msfcn_unit_delay.m performs the previous list of steps:
If your S-function needs continuous states, initialize the number of continuous states in the setup method using the run-time object's NumContStates property. Do not initialize discrete states in the setup method.
Initialize the discrete states in the PostPropagationSetup method. A Level-2 MATLAB S-function stores discrete state information in a DWork vector. The default PostPropagationSetup method in the template file suffices for this example.
The following PostPropagationSetup method from msfcn_unit_delay.m, named DoPostPropSetup, initializes one DWork vector with the name x0.
If your S-function uses additional DWork vectors, initialize them in the PostPropagationSetup method, as well (see Using DWork Vectors in Level-2 MATLAB S-Functions).
Initialize the values of discrete and continuous states or other DWork vectors in the InitializeConditions or Start callback methods. Use the Start callback method for values that are initialized once at the beginning of the simulation. Use the InitializeConditions method for values that need to be reinitialized whenever an enabled subsystem containing the S-function is reenabled.
For this example, use the InitializeConditions method to set the discrete state's initial condition to the value of the S-function's dialog parameter. For example, the InitializeConditions method in msfcn_unit_delay.m is:
For S-functions with continuous states, use the ContStates run-time object method to initialize the continuous state date. For example:
Calculate the S-function's outputs in the Outputs callback method. For this example, set the output to the current value of the discrete state stored in the DWork vector.
The Outputs method in msfcn_unit_delay.m is:
For an S-function with continuous states, calculate the state derivatives in the Derivatives callback method. Run-time objects store derivative data in their Derivativesproperty. For example, the following line sets the first state derivative equal to the value of the first input signal.
This example does not use continuous states and, therefore, does not implement the Derivatives callback method.
Update any discrete states in the Update callback method. For this example, set the value of the discrete state to the current value of the first input signal.
The Update method in msfcn_unit_delay.m is:
Perform any cleanup, such as clearing variables or memory, in the Terminate method. Unlike C MEX S-functions, Level-2 MATLAB S-function are not required to have a Terminate method.