I am trying to convert a Matlab code to Python, and I'm facing a problem when I convert a line. Am I right or not? I don't know how to do assignment in Python.
Matlab:
for j=1:a
diff_a=zeros(1,4);
diff_b=zeros(1,4);
for i=1:4
diff_a(i)=abs(ssa(j)-check(i));
diff_b(i)=abs(ssb(j)-check(i));
end
[Y_a,I_a]=min(diff_a);
end
Python:
for j in arange(0,a):
diff_a=zeros(4)
diff_b=zeros(4)
for i in arange(0,4):
diff_a[i]=abs(ssa[j]-check[i])
diff_b[i]=abs(ssb[j]-check[i])
[Y_a,I_a]=min(diff_a)
the last line gives this error:
TypeError: 'numpy.float64' object is not iterable
The problem is in the last line. diff_a is a complex number array. Sorry for not providing the whole code (it's too big).
realandimagmethods.diff_a.min()rather?