only length-1 arrays can be converted to Python scalar

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Altynay
    New Member
    • Mar 2013
    • 1

    only length-1 arrays can be converted to Python scalar

    Hi all!
    Could somebody help me. I have error: only length-1 arrays can be converted to Python scalar
    Code:
    import math
    k=6*(10**-8)
    Q=100
    h=50
    a=7
    zp=-a
    zi=a
    z=0
    E=Q/2*math.pi*k*h
    import numpy as np
    def func(x,y):
        return z
    W = np.arange(10)
    x = np.arange(10)
    y = np.arange(10)
    z=x+y*1j
    W=E*math.log((z-zp)/(z-zi))
    print func(W)
    in this programm. Thanks for attention
    Last edited by bvdet; Mar 14 '13, 02:12 PM. Reason: Please use code tags when posting code
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    math.log() requires a number and you are providing an array.

    Comment

    Working...