Physics 109

Dr. Ayars

Python Example code

from pylab import *

t,v = loadtxt("N2data",unpack=True)
omega = pi/t

params, cov = polyfit(omega,v,1,cov=True)

plot(omega,v, 'go')
plot(omega, params[0]*omega+params[1], 'r-')

title("Demonstration of Linear Fitting")
xlabel("$\omega$ (rad/s)")
ylabel("V (mV)")

print("slope = ", params[0])

show()