【问题标题】:How to create a plot with the negative values of a noisy signal?如何使用噪声信号的负值创建图?
【发布时间】:2017-09-14 13:54:19
【问题描述】:

所以我必须生成一个从 0 到 2 pi 的 cos 函数,并添加具有零均值和 0.5 标准偏差的高斯噪声然后我必须为以下各项创建不同的图:

a) 有噪声的信号和没有噪声的信号

我已经完成了:

clear
close all
% Plot cos function from 0 to 2 pi
x = linspace(0, 2*pi, 1000);
y1 = cos(x);
noise =  .3*randn(1,1000);
prob1a = y1 + noise;
figure
plot(x, y1, x, prob1a)

b) 绘制噪声信号的负值
c) 绘制噪声信号的正值

我需要 b 和 c 部分的帮助。

【问题讨论】:

    标签: matlab


    【解决方案1】:

    这是你想要的吗?

    figure()
    pos_noise = noise;
    pos_noise(pos_noise < 0) = 0;
    plot(x, pos_noise)
    hold all
    neg_noise = noise;
    neg_noise(neg_noise > 0) = 0;
    plot(x, neg_noise)
    

    【讨论】:

      猜你喜欢
      • 2022-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-25
      • 1970-01-01
      • 2014-02-22
      • 1970-01-01
      • 2015-10-11
      相关资源
      最近更新 更多