【问题标题】:Plotting random signal on circle在圆圈上绘制随机信号
【发布时间】:2015-06-23 09:58:11
【问题描述】:

我有一些带有时间刻度的随机信号(例如sin 信号)。

t=0:0.1:2*pi
y=sin(t)
plot(t,y)

现在我想在这个圆圈上画出这个信号。所以时间向量实际上变成了圆的包络。圆圈的包络表示笛卡尔坐标系中的“y = 0”。

以下是我期望输出的示例:

(来源:slikomat.com

提前致谢!

【问题讨论】:

  • 您尝试过什么?首先,只需绘制圆圈。然后尝试添加您的y,看看会发生什么。我想你会发现你还需要添加一个x 随机信号,但你至少需要自己尝试一下!

标签: matlab plot signals geometry


【解决方案1】:

根据我之前对How to plot a circle?的回答:

%// radius
r = 2;

%// center
c = [3 3];

%// number of points
n = 1000;

%// running variable
t = linspace(0,2*pi,n);

%// noise
noise_frequency_factor = 20;
noise_amplification = 0.1*r;
noise_function = @(a,b,x) a*(sin(b*x) + 1);
noise = noise_function(noise_amplification,noise_frequency_factor,t);

%// circle with noise
x = c(1) + (r+noise).*sin(t);
y = c(2) + (r+noise).*cos(t);

%// draw line
line(x,y)

%// envelope circle
x = c(1) + (r).*sin(t);
y = c(2) + (r).*cos(t);

%// draw line
line(x,y,'color','r')

%// or draw polygon if you want to fill it with color
%// fill(x,y,[1,1,1])
axis equal

【讨论】:

    【解决方案2】:

    你需要给圆的半径加上“噪音”,大致在r=1左右:

    th = linspace( 0, 2*pi, N ); %// N samples
    noise = rand( 1, N ) * .1; %// random noise in range [0..0.1]
    r = 1+noise; %// add noise to r=1
    figure;
    plot( r.*cos(th), r.*sin(th) ); title('noise on circle');
    

    示例图如下所示:

    【讨论】:

    • 非常感谢。这帮助我分配!我试图在圆形信封周围绘制心率。我在你的帮助下做到了!
    【解决方案3】:

    更简单的方法是使用polar

    t = linspace(0,2*pi,1000);
    y = .1*sin(t*30); %// amplitude .1 and frequency 30, relative to circle
    polar(t, 1+y);
    

    如果要删除polar生成的文字,使用

    delete(findall(gca, 'type', 'text'))
    

    【讨论】:

      猜你喜欢
      • 2019-01-17
      • 1970-01-01
      • 2015-07-04
      • 1970-01-01
      • 1970-01-01
      • 2018-08-09
      • 1970-01-01
      • 2017-12-15
      • 2018-03-24
      相关资源
      最近更新 更多