虽然我导入了plot_histogram
,但我没有得到预期的输出。这是我的代码:
a = QuantumCircuit(1)
a.z(0)
a.x(0)
a.h(0)
a.sdg(0)
a.t(0)
backend = Aer.get_backend('qasm_simulator')
result = execute(a, backend).result()
counts = result.get_counts()
plot_histogram(counts)
print(c)```
Run Code Online (Sandbox Code Playgroud)
小智 5
您缺少测量值。
a.z(0)
a.x(0)
a.h(0)
a.sdg(0)
a.t(0)
a.measure_all(). #<--
...
Run Code Online (Sandbox Code Playgroud)
这将测量量子位并用结果设置一个经典寄存器。
归档时间: |
|
查看次数: |
2237 次 |
最近记录: |