1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Hi, I'm doing a program to draw a curve of the tension squared as a function of the...

Discussão em 'Python' iniciado por Stack, Setembro 14, 2024.

  1. Stack

    Stack Membro Participativo

    This is my script, it's to draw a curve of the tension squared as a function of the inverse of the distance squared:

    import numpy as np
    import matplotlib.pyplot as plt

    plt.title("Courbe de la tension en fonction de la distance à l'émeteur")

    d = [0.1,0.12,0.15,0.2,0.25,0.3,0.4]
    A = []
    for n in range (len(d)):
    A.append (1/(d[n]**2))

    U = [0.456,0.340,0.304,0.224,0.172,0.152,0.116]

    B = [ ]
    for n in range (len(U)):
    B.append (U[n]**2)

    plt.plot(B, A)

    plt.xlabel("inverse de la distance en m au carré")
    plt.ylabel("tension au carrée")

    modele= np.polyfit(A,B,1)
    plt.plot(A, modele[0]*A + modele[1])

    plt.show()


    And this is the error:

    Traceback (most recent call last):
    File "<module1>", line 23, in <module>
    TypeError: can't multiply sequence by non-int of type 'numpy.float64'
    >>>


    I don't fully understand this : can't multiply sequence by non-int of type 'numpy.float64'

    Can you please tell me how to change my script so that I can model it ?

    Continue reading...

Compartilhe esta Página