0
我正在计划绘制y^n vs x对于不同的n值。下面是我的示例代码:将数组提升为不同的值
import numpy as np
x=np.range(1,5)
y=np.range(2,9,2)
exponent=np.linspace(1,8,50)
z=y**exponent
有了这个,我得到了以下错误:
ValueError: operands could not be broadcast together with shapes (4) (5)
我的想法是,对于n的每个值,我会在那里数组包含新得到一个数组现在将y的值提高到n。例如:
y1= [] #an array where y**1
y2= [] #an array where y**1.5
y3= [] #an array where y**2
等。我不知道我是否可以得到这50个数组为y ** n,有没有更容易的方法来做到这一点?谢谢。