小编H4Z*_*4RD的帖子

“只有大小为 1 的数组可以转换为 Python 标量”

我有这个代码:

R = float(input("Enter the arc's radius of curvature: "))

H = float(input("Enter the arc's height: "))

import matplotlib.pyplot as plt

import numpy as np

import math

#cc = center of curvature

cc = math.sqrt(R**2 - (H / 2)**2)

x = np.linspace(-5,5,100)

y = math.sqrt(R**2 - (x - cc)**2)

plt.plot(x, y, 'c')

plt.show()
Run Code Online (Sandbox Code Playgroud)

并收到此错误:

类型错误:只有大小为 1 的数组可以转换为 Python 标量

我怎样才能解决这个问题?

python math numpy matplotlib

5
推荐指数
1
解决办法
8007
查看次数

标签 统计

math ×1

matplotlib ×1

numpy ×1

python ×1