Domanda

I'm trying to make an exponential fit to find the Lyapunov Exponent of this data, however, I keep getting this error:

m=math.log10(abs(x))
TypeError: only length-1 arrays can be converted to Python scalars    

and here's the code:

f=np.loadtxt('Single Small Angle 1.txt',unpack=True,skiprows=2)
g=np.loadtxt('Single Small Angle 5.txt',unpack=True,skiprows=2)

x = f-g[:,:11944]
t=range(len(x))
m=math.log10(abs(x))

np.polyfit(t,m)

plt.plot(t,abs(x))
#plt.xlabel("${\Theta}$ [rad]")
#plt.ylabel("${\Omega}$ [rad/s]")
#plt.title("Small Angle Approximation Phase Space")
plt.show()

Nessuna soluzione corretta

Altri suggerimenti

You should use np.log10() instead of math.log10. The built-in math library does not handle numpy arrays, so the numpy log10 function is more appropriate.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top