如何使用fct迭代2D矩阵?
在伪代码中,它应如下所示:
import cmath as cm
matrixphase = 0
complexmatrix = fouriertransformation of an image
for each entry:
matrixphase[i,j]= cm.phase(complexmatrix[i,j])
print(matrix phase)
我认为有一个非常简单的解决方案,但是我只是不知道解决方法。
答案 0 :(得分:0)
您的问题没有提及名为source
的列表,
但是想象一下我们有一个。
然后,C程序员可能会使用嵌套的i
,j
for
循环,
而pythonista倾向于支持enumerate
:
for i, row in enumerate(source):
for j, item in enumerate(row):
...
如果您要显示项目或计算简单金额, 因此不需要索引 那么就足够了:
for row in source:
for item in row:
...