Installation Required: This functionality requires MATLAB Support Package for Quantum Computing.
Hadamard Gate and Its Matrix Representation
Create a Hadamard gate that acts on a single qubit.
g = hGate(1)
g = SimpleGate with properties: Type: "h" ControlQubits: [1×0 double] TargetQubits: 1 Angles: [1×0 double]
Get the matrix representation of the gate.
M = getMatrix(g)
M = 0.7071 0.7071 0.7071 -0.7071
Array of Hadamard Gates
Create an array of Hadamard gates that act on qubits with indices 1 to 4.
g = hGate(1:4)
g = 4×1 SimpleGate array with gates: Id Gate Control Target 1 h 1 2 h 2 3 h 3 4 h 4
targetQubit — Target qubit of gate
positive integer scalar | positive integer vector
Target qubit of the gate, specified as a positive integer scalar index or vector of qubit indices.
Matrix Representation of Hadamard Gate
The matrix representation of a Hadamard gate applied to a single qubit is
This gate maps the qubit basis states from the Z basis to the X basis (and from the X basis to the Z basis), where the and states are mapped to the and states, respectively.
Introduced in R2023a