# idGate

Identity gate

Since R2023a

Installation Required: This functionality requires MATLAB Support Package for Quantum Computing.

## Syntax

``g = idGate(targetQubit)``

## Description

example

````g = idGate(targetQubit)` applies an identity gate to a single target qubit and returns a `quantum.gate.SimpleGate` object.If `targetQubit` is a vector of qubit indices, `idGate` returns a column vector of gates, where `g(i)` represents an identity gate applied to a qubit with index `targetQubit(i)`.```

## Examples

collapse all

Create an identity gate that acts on a single qubit.

`g = idGate(1)`
```g = SimpleGate with properties: Type: "id" ControlQubits: [1×0 double] TargetQubits: 1 Angles: [1×0 double]```

Get the matrix representation of the gate.

`M = getMatrix(g)`
```M = 1 0 0 1```

Create an array of identity gates that act on qubits with indices 1 to 4.

`g = idGate(1:4)`
```g = 4×1 SimpleGate array with gates: Id Gate Control Target 1 id 1 2 id 2 3 id 3 4 id 4 ```

## Input Arguments

collapse all

Target qubit of the gate, specified as a positive integer scalar index or vector of qubit indices.

Example: `1`

Example: `3:5`

collapse all

### Matrix Representation of Identity Gate

The matrix representation of an identity gate applied to a single qubit is

`$\left[\begin{array}{cc}1& 0\\ 0& 1\end{array}\right].$`

This gate leaves the qubit state unchanged.

## Version History

Introduced in R2023a