【问题标题】:Beginner programmer trying to graph an equation in python初学者程序员试图在 python 中绘制方程
【发布时间】:2020-07-20 05:06:20
【问题描述】:

鉴于此梁偏转方程,我被要求绘制它,但我不断收到此错误消息:

这是我的代码:

import math
import matplotlib.pyplot as plt
import scipy.constants
import numpy as np

p_l = 2.5
E = 50000
I = 30000
L = 600

fsy = 6
fsx = scipy.constants.golden

dx = 0.01
x_max = 100
x = np.arange(0.0, x_max + dx, dx)

v_x = ((p_l)/(E*I*L))*((-x**5)+(2(600**2)*(x**3))-(600**4)*x)

fig = plt.figure(figsize = (fsx, fsy))

plt.plot(x, v_x, color = 'k', linestyle = '-', linewidth = 2.0, marker = '.')

plt.title("Plot of v(x)", fontsize=15)
plt.xlabel(" ($s$)")
plt.ylabel("$y$ ($m$)")
plt.ylim(-105, 105)
plt.legend()
plt.show()

这是我不断收到的错误消息:

TypeError                                 Traceback (most recent call last)
<ipython-input-37-4d6b17714a72> in <module>
     18 x = np.arange(0.0, x_max + dx, dx)
     19 
---> 20 v = ((p_l)/(E*I*L))*((-x**5)+(2(600**2)*(x**3))-(600**4)*x)
     21 
     22 fig = plt.figure(figsize = (fsx, fsy))

TypeError: 'int' object is not callable

如果可以的话请帮忙!非常感谢

【问题讨论】:

标签: python plot


【解决方案1】:

在 Python 中,您需要在进行乘法运算时添加 * 符号。将其添加到 2600**2 之间。如下图!

(2*(600**2)

v_x = ((p_l)/(E*I*L))*((-x**5)+(2*(600**2)*(x**3))-(600**4)*x)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-12
    • 1970-01-01
    • 2013-04-17
    • 1970-01-01
    相关资源
    最近更新 更多