Jul 1, 2015 #1 rj771972 Programmer May 17, 2013 10 US Hello, In Matlab I can do in one line: c=a+j*b where j=sqrt(-1) and a,b,c are arrays. Can I do this in python using cmath? Thanks Robert
Hello, In Matlab I can do in one line: c=a+j*b where j=sqrt(-1) and a,b,c are arrays. Can I do this in python using cmath? Thanks Robert
Jul 5, 2015 #2 salgerman Programmer Jan 14, 2010 520 US I don't think cmath works on arrays, only on scalars (or length-1 arrays). The thing is that you don't need cmath for what you want to do, all you need are numpy arrays; you operation would than look like this: c = a + b*1j j is already defined in python and it can be best used with the accompanying 1, i.e., "1j" Upvote 0 Downvote
I don't think cmath works on arrays, only on scalars (or length-1 arrays). The thing is that you don't need cmath for what you want to do, all you need are numpy arrays; you operation would than look like this: c = a + b*1j j is already defined in python and it can be best used with the accompanying 1, i.e., "1j"