编辑代码

import numpy as np
import matplotlib.pyplot as plt

# 参数设置
theta = np.linspace(0, 2*np.pi, 1000)  # 极角范围
frequency = 5.8e9  # ETC频率(5.8GHz)
wavelength = 3e8 / frequency           # 波长

# 用理论模型模拟定向天线方向图(简化模型)
def radiation_pattern(theta):
    # 主瓣指向正方向(θ=0),旁瓣衰减
    main_lobe = np.cos(theta) ** 20    # 主瓣形状
    side_lobe = 0.1 * np.sin(2*theta)  # 旁瓣扰动
    return np.abs(main_lobe + side_lobe)

# 生成辐射数据
r = radiation_pattern(theta)  # 辐射强度

# 绘图
fig = plt.figure(figsize=(8,8))
ax = fig.add_subplot(111, polar=True)
ax.plot(theta, r, color='red', linewidth=2)

ax.set_title("ETC RF信号辐射方向图(示例,5.8GHz)", pad=20)
ax.grid(True)
ax.set_theta_zero_location('N')  # 主瓣指向正上方(类似真实ETC天线布局)
plt.show()