Python: I need to get the area below a curve

Asked

Viewed 38 times

0

This is my code:

index = 0

T = np.zeros((300,1))

T[:,0] = np.linspace(0.01, 3, 300)[:]

A = np.loadtxt('AAA_'+str(index)+'.txt')

Tr = 1.0

idx = (abs(T-(Tr))).argmin()

a = T[:idx+1]

a = [i[0] for i in a]

b = A[:idx+1]

area = np.trapz(a, b)

        
plt.plot(T, A)

plt.show()

inserir a descrição da imagem aqui

My goal is to get the area marked in red in the figure, and I do not know the function that defines the blue curve. I tried to integrate using the rule of trapezoids, however without success. What am I doing wrong? Any suggestions to try to solve this problem?

Thank you!

  • 1

    That helping?

  • @Paulomarques Helped yes! Thank you very much for your attention!!!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.