# cnotGate

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

## Description

applies a controlled NOT gate to a target qubit based on the state of a control qubit and
returns a `g`

= cnotGate(`controlQubit`

,`targetQubit`

)`quantum.gate.SimpleGate`

object. If the control qubit is in the $$|0\rangle $$ state, then this gate does nothing. If the control qubit is in the $$|1\rangle $$ state, then this gate applies a Pauli X or NOT gate
(`xGate`

) to the target qubit. This gate is also known as the controlled
X gate, and `cnotGate`

is equivalent to the `cxGate`

.

If

`controlQubit`

and`targetQubit`

are vectors of the same length,`cnotGate`

returns a column vector of gates, where`g(i)`

represents a controlled NOT gate applied to a control qubit with index`controlQubit(i)`

and a target qubit with index`targetQubit(i)`

.If either

`controlQubit`

or`targetQubit`

is a scalar, and the other input is a vector, then MATLAB^{®}expands the scalar to match the size of the vector input.The qubit indices in each element pair of

`controlQubit`

and`targetQubit`

must not be the same.

## Examples

## Input Arguments

## More About

## Version History

**Introduced in R2023a**

## See Also

`quantumCircuit`

| `quantum.gate.SimpleGate`

| `xGate`

| `cxGate`

| `cyGate`

| `czGate`

| `ccxGate`

| `getMatrix`