Code:
# Imported array of data from a text file. This code works with no problems.
q1, a1 = loadtxt("values.txt", unpack = True, skiprows = 1)
print q1
print a1
# Creating a while loop for this part of the code. This code works with no problems.
a = 3
b = -2
c = -9
q = 0.5
qt = 0.1
while q < 1.5:
print q, a
q += qt
a = a + b*qt
b = b + c*qt
# This interpolation does not work. I am unable to figure it out.
# TypeError: object of type 'float' has no len()
from scipy.interpolate import interp1d
f = interp1d(q,a,'cubic')
q1 = linspace(0.5,1.4,25)
a1 = f(q1)
plot(q1,a1, '-', q,a, 'o')
show()