sim(idnlhw)

Simulate Hammerstein-Wiener model

Syntax

YS = sim(MODEL,U)
YS = sim(MODEL,U,'Noise')
YS = sim(MODEL,U,'InitialState',INIT)

Description

YS = sim(MODEL,U) simulates the output of an idnlhw model.

YS = sim(MODEL,U,'Noise') simulates the model output with an additive Gaussian noise scaled according to the value of the NoiseVariance property of MODEL.

YS = sim(MODEL,U,'InitialState',INIT) specifies initial conditions for starting the simulation.

To simulate the model with user-defined noise, set the input U = [UIN E], where UIN is the input signal and E is the noise signal. UIN and E must both be one of the following:

  • iddata objects: E stores the noise signals as inputs, where the number of inputs matches the number of model outputs.

  • Matrices: E has as many columns as there are noise signals, corresponding to the number of model outputs.

Input Arguments

  • MODEL: idnlhw model object.

  • U: Input data for simulation, which is an iddata object (where only the input channels are used) or a matrix. For simulations with noisy data, U contains both input and noise channels.

  • INIT: Initial condition for simulation. INIT has one of the following values:

    • Vector of initial state values. To estimate an initial state vector from input-output data or to generate equilibrium states, see the findstates(idnlhw) and findop(idnlhw) reference pages. For multiple-experiment data, enter a matrix with the same number of columns as the number of experiments.

    • 'z': (Default) Vector containing zeros and corresponding to a system starting from rest.

Output Arguments

  • YS: Simulated output, which is an iddata object when U is an iddata object, or a matrix otherwise.

    Note:   If sim is called without an output argument, MATLAB® software displays the simulated output(s) in a plot window.

Examples

Simulation Using Initial States to Best Fit Model Response to Measured Output

In this example you simulate the model output using initial states that minimize the error between the simulated and the measured output. z2 is the measured data.

  1. Load the sample data.

    load iddata2
    
  2. Create a Hammerstein-Wiener model.

    M = nlhw(z2,[4 3 2],'wave','pwl');
    
  3. Compute the initial states that best fit the model response to the measured output.

    x0 = findstates(M,z2);
    
  4. Simulate the model using the estimated initial states.

    ysim = sim(M,z2.u,'init',x0)
    
  5. Compare ysim to output signal in z2:

    t = z2.samp;
    plot(t, ysim, t, z2.y) 

Simulating a Hammerstein-Wiener Model at Steady-State with Known Input and Unknown Output

In this example, you simulate a single-input single-output idnlhw model about a steady-state operating point, where the input level is known to be 1 and the output level is unknown.

  1. Load the sample data.

    load iddata2
    
  2. Create a Hammerstein-Wiener model.

    M = nlhw(z2,[4 3 2],'wave','pwl');
  3. Compute steady-state operating point values corresponding to an input level of 1 and an unknown output level.

    x0 = findop(M,'steady',1,NaN); 
  4. Simulate the model using the estimated initial states.

    sim(M,z2.u,'init',x0)
Was this topic helpful?