Import the required modules:
Code: Select all
from qiskit import QuantumCircuit
from qiskit.extensions import UnitaryGate
Code: Select all
matrix = [[1, 0, 0, 0],
[0, 0, 1, 0],
[0, 1, 0, 0],
[0, 0, 0, 1]]
Code: Select all
qc = QuantumCircuit(2)
qc.append(gate, [0, 1]) # Applying the gate to qubits 0 and 1
Note: The matrix you provide should be unitary and compatible with the number of qubits in your circuit.