18222691126的个人空间 https://blog.eetop.cn/1535259 [收藏] [复制] [分享] [RSS]

空间首页 动态 记录 日志 相册 主题 分享 留言板 个人资料

日志

使用python生成带噪声且带EMI的正弦波数据作为激励

已有 104 次阅读| 2024-4-11 18:44 |个人分类:验证|系统分类:芯片设计

  # 设置参数

    fs = 5000  # 采样频率

    f = 500  # 正弦信号频率

    amp = 10000  # 正弦信号幅度

    duration = 0.07  # 信号持续时间


    # 生成时间序列

    t = np.arange(0, duration, 0.01 / fs)


    # 生成正弦信号

    x = amp * np.sin(2 * np.pi * f * t)


    #生成第二个幅度较高的正弦波,然后截取该正弦波的部分,与第一个正弦波叠加

    # 设置参数

    fs2 = 5000  # 采样频率

    f2 = 1000  # 正弦信号频率

    amp2 = 60000  # 正弦信号幅度

    duration2 = 0.07  # 信号持续时间

    # 生成时间序列

    t2 = np.arange(0, duration2, 0.01 / fs2)

    # 生成正弦信号

    x2 = amp2 * np.sin(2 * np.pi * f2 * t2)



    start_index2 = np.random.randint(0,len(x2)-13000)

    result = x2[start_index2: start_index2 + 100]

    result2 = np.random.normal(0,0,start_index2)

    result3 = np.random.normal(0,0,len(x2)-start_index2-100)

    result4 = np.append(result2,result)

    result5 = np.append(result4,result3)


    # 生成第三个幅度较高的正弦波,然后截取该正弦波的部分,与第一个正弦波叠加

    # 设置参数

    fs3 = 5000  # 采样频率

    f3 = 1000  # 正弦信号频率

    amp3 = 40000  # 正弦信号幅度

    duration3 = 0.07  # 信号持续时间

    # 生成时间序列

    t3 = np.arange(0, duration3, 0.01 / fs3)

    # 生成正弦信号

    x3 = amp3 * np.sin(2 * np.pi * f3 * t3)


    start_index3 = np.random.randint(0, len(x3) - 13000)

    result6 = x3[start_index3: start_index3 + 100]

    result7 = np.random.normal(0, 0, start_index3)

    result8 = np.random.normal(0, 0, len(x3) - start_index3 - 100)

    result9 = np.append(result7, result6)

    result10 = np.append(result9, result8)


    # 生成第四个幅度较高的正弦波,然后截取该正弦波的部分,与第一个正弦波叠加

    # 设置参数

    fs4 = 5000  # 采样频率

    f4 = 1000  # 正弦信号频率

    amp4 = 20000  # 正弦信号幅度

    duration4 = 0.07  # 信号持续时间

    # 生成时间序列

    t4 = np.arange(0, duration4, 0.01 / fs4)

    # 生成正弦信号

    x4 = amp4 * np.sin(2 * np.pi * f4 * t4)


    start_index4 = np.random.randint(0, len(x4) - 13000)

    result11 = x4[start_index4: start_index4 + 100]

    result12 = np.random.normal(0, 0, start_index4)

    result13 = np.random.normal(0, 0, len(x4) - start_index4 - 100)

    result14 = np.append(result12, result11)

    result15 = np.append(result14, result13)


    noise = np.random.normal(0, 500, len(x))

    # 添加噪声

    x_noise = 1000000 + x   + noise + result5 + result10 + result15


    y = np.around(x_noise,0)

    np.set_printoptions(threshold=np.inf)

    with open('/Users/huqixing914/Desktop/project/emi_det.txt', 'w') as f:

         print(y,end='\n', file=f)


    # 绘制图像

    plt.plot(t, x_noise)

    plt.xlabel('Time (s)')

    plt.ylabel('Amplitude')

    plt.show()


image.png


点赞

评论 (0 个评论)

facelist

您需要登录后才可以评论 登录 | 注册

  • 关注TA
  • 加好友
  • 联系TA
  • 0

    周排名
  • 14

    月排名
  • 0

    总排名
  • 1

    关注
  • 1

    粉丝
  • 0

    好友
  • 1

    获赞
  • 1

    评论
  • 2

    访问数
关闭

站长推荐 上一条 /1 下一条

小黑屋| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-5-9 05:49 , Processed in 0.025602 second(s), 15 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
返回顶部