---
url: /dyad/dev/stdlib/DiscreteComponents/components/Examples.MatrixGain.md
description: >-
  Dyad Examples.MatrixGain docs. 
  DiscreteComponents.Examples.MatrixGain(K=[[1.0, 0.0], [0.0, 1.0]])
---

# `Examples.MatrixGain` {#Examples.MatrixGain}

## Usage {#Usage}

`DiscreteComponents.Examples.MatrixGain(K=[[1.0, 0.0], [0.0, 1.0]])`

## Parameters: {#Parameters:}

| Name | Description | Units |      Default value |
| ----:| -----------:| -----:| ------------------:|
| `ny` |             |     – |                  2 |
| `nu` |             |     – |                  2 |
|  `K` |             |     – | \[1.0 0.0; 0.0 1.0] |

## Connectors {#Connectors}

* `y` - This connector represents a real signal as an output from a component ([`RealOutput`](/stdlib/Dyad/connectors/RealOutput#RealOutput))

* `u` - This connector represents a real signal as an input to a component ([`RealInput`](/stdlib/Dyad/connectors/RealInput#RealInput))

## Behavior {#Behavior}

$$ \begin{align}
y\_{1}\left( t \right) &= K\_{1,1} ~ u\_{1}\left( t \right) + K\_{1,2} ~ u\_{2}\left( t \right) \\
y\_{2}\left( t \right) &= K\_{2,1} ~ u\_{1}\left( t \right) + K\_{2,2} ~ u\_{2}\left( t \right)
\end{align}
$$

## Source {#Source}

```dyad
component MatrixGain
  y = [Dyad.RealOutput() for i in 1:ny] {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  u = [Dyad.RealInput() for i in 1:nu] {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  structural parameter ny::Integer = 2
  structural parameter nu::Integer = 2
  parameter K::Real[ny, nu] = [[1.0, 0.0], [0.0, 1.0]]
relations
  y = K * u
end
```

```dyad
component MatrixGain
  y = [Dyad.RealOutput() for i in 1:ny] {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 1000, "y1": 450, "x2": 1100, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  u = [Dyad.RealInput() for i in 1:nu] {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0}
      },
      "tags": []
    }
  }
  structural parameter ny::Integer = 2
  structural parameter nu::Integer = 2
  parameter K::Real[ny, nu] = [[1.0, 0.0], [0.0, 1.0]]
relations
  y = K * u
metadata {}
end
```

## Test Cases {#Test-Cases}

No test cases defined.

## Related {#Related}

* Examples

* Experiments

* Analyses
