---
url: /dyad/dev/stdlib/DiscreteComponents/tests/Examples.TestZeroOrderHold.md
description: >-
  Dyad Examples.TestZeroOrderHold docs.  Test that the output of a zero-order
  hold block resembles the integral of the continuous-time input signal.
---

# `Examples.TestZeroOrderHold` {#Examples.TestZeroOrderHold}

Test that the output of a zero-order hold block resembles the integral of the continuous-time input signal.

## Usage {#Usage}

`DiscreteComponents.Examples.TestZeroOrderHold()`

## Behavior {#Behavior}

Behavior of this component cannot be rendered because it includes `path` variables.

## Source {#Source}

```dyad
"""
Test that the output of a zero-order hold block resembles the integral
of the continuous-time input signal.
"""
test component TestZeroOrderHold
  sine = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 70, "y1": 450, "x2": 170, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  zeroorderhold = DiscreteComponents.ZeroOrderHold() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 430, "y1": 450, "x2": 530, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  sampler = DiscreteComponents.Sampler() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 250, "y1": 450, "x2": 350, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  periodicclock = DiscreteComponents.PeriodicClock(dt = 0.1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 250, "y1": 600, "x2": 350, "y2": 700, "rot": 0}
      },
      "tags": []
    }
  }
  integrator = BlockComponents.Continuous.Integrator() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 610, "y1": 450, "x2": 710, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
relations
  connect(sine.y, sampler.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(sampler.y, zeroorderhold.u, periodicclock.y) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(zeroorderhold.y, integrator.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
metadata {"Dyad": {"doc": {"behavior": false}}}
end
```

```dyad
"""
Test that the output of a zero-order hold block resembles the integral
of the continuous-time input signal.
"""
test component TestZeroOrderHold
  sine = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 70, "y1": 450, "x2": 170, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  zeroorderhold = DiscreteComponents.ZeroOrderHold() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 430, "y1": 450, "x2": 530, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  sampler = DiscreteComponents.Sampler() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 250, "y1": 450, "x2": 350, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  periodicclock = DiscreteComponents.PeriodicClock(dt = 0.1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 250, "y1": 600, "x2": 350, "y2": 700, "rot": 0}
      },
      "tags": []
    }
  }
  integrator = BlockComponents.Continuous.Integrator() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 610, "y1": 450, "x2": 710, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
relations
  connect(sine.y, sampler.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(sampler.y, zeroorderhold.u, periodicclock.y) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
  connect(zeroorderhold.y, integrator.u) {"Dyad": {"renderStyle": "standard", "edges": [{"S": 1, "E": 2, "M": []}]}}
metadata {"Dyad": {"doc": {"behavior": false}}}
end
```

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`Integrator`](Examples.TestZeroOrderHold.md)

  * [`PeriodicClock`](Examples.TestZeroOrderHold.md)

  * [`Sampler`](Examples.TestZeroOrderHold.md)

  * [`Sine`](Examples.TestZeroOrderHold.md)

  * [`ZeroOrderHold`](Examples.TestZeroOrderHold.md)
