1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
   | import matplotlib.pyplot as plt
import numpy as np
from math import *
 
#Les fonctions------------------------------------------------------
 
def calcul_vitesses(abscisses,ordonnees,temps):
    v_x=[]
    v_y=[]
    for n in range(len(abscisses)-1):
        v_x.append((abscisses[n+1]-abscisses[n])/(temps[n+1]-temps[n]))
        v_y.append((ordonnees[n+1]-ordonnees[n])/(temps[n+1]-temps[n]))
    temps=temps[:-1]
    return v_x,v_y,temps
 
def calcul_deltaV_deltat(v_x, v_y,temps_v):
    a_x=[]
    a_y=[]
    a=[]
    for i in range(1,len(v_x)):
        a_x.append((v_x[i]-v_x[i-1])/(temps_v[i]-temps_v[i-1]))
        a_y.append((v_y[i]-v_y[i-1])/(temps_v[i]-temps_v[i-1]))
    for i in range(len(a_x)):
        a.append(sqrt(a_x[i]**2+a_y[i]**2))
    t=temps_v[1:]
    return a, t
 
def representation_graphique(a,t):
    t=np.array(t)
    a=np.array(a)
    moy=np.mean(a)
    plt.scatter(t,a,marker='+')
    plt.plot(t,0*t+9.8,color='red',label=r'$\displaytyle{\frac{F}{m}}$')
    plt.plot(t,0*t+moy,color='green', label='moyenne')
    plt.title(r'$\frac{\Delta v}{\Delta t} = f(t)$')
    plt.xlabel(r'$t \ (s)$')
    plt.ylabel(r'$\frac{\Delta v}{\Delta t} \ (m.s^{-2})$')
    plt.xlim(0,1.2*max(t))
    plt.ylim(0,15)
    plt.grid()
    plt.legend()
    plt.show()
 
#Le programme principal--------------------------------------------
 
x=[0.00,0.50,1.00,1.50,2.00,2.50,3.00,3.50,4.00,4.50,5.00]
z=[5.00,4.95,4.80,4.56,4.22,3.77,3.23,2.60,1.86,1.03,0.09]
t=[0.00,0.10,0.20,0.30,0.40,0.50,0.60,0.70,0.80,0.90,1.00]
 
v_x,v_y,temps_v=calcul_vitesses(x,z,t)
a, t =calcul_deltaV_deltat(v_x,v_y,temps_v)
representation_graphique(a,t) | 
Partager