Challenge

Week 5 - Curve fitting

import math
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
import numpy as np

#Reading thermodynamic data file
def read_file():
temperature=[]
cp=[]
for line in open('data','r'):
values=line.split(',')
temperature.append(float(values[0])) #Here tempearture values are stored from data
cp.append(float(values[1])) #Here cp values are stored from data

return [temperature,cp]
temperature,cp=read_file()
z=np.polyfit(temperature,cp,4)
p=np.poly1d(z)
print(p,2000)
print(z)

plt.plot(temperature,cp)
plt.show()

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.