TypeError: only length-1 arrays can be converted to Python scalars with NUMPY

前端 未结 2 1823
-上瘾入骨i
-上瘾入骨i 2021-01-14 15:30
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt 
import numpy as np 
import math


#task 2e

x = np.linspace(-0.0001,0.1,50) 

#constants
e0=8.85*10 ** (-12)         


        
2条回答
  •  被撕碎了的回忆
    2021-01-14 16:12

    use np instead of math.sqrt

    v=(Q/((4*math.pi*e0)*(np.sqrt((x**2+r0**2)))))
    
    
    v2=v+(Q2/((4*math.pi*e0)*(np.sqrt(((x-2)**2+r2**2)))))
    

提交回复
热议问题