在圆上绘制随机信号
Plotting random signal on circle
我有一些带有时标的随机信号(例如 sin
信号)。
t=0:0.1:2*pi
y=sin(t)
plot(t,y)
现在我想在这个圆上画这个信号。所以时间向量实际上变成了圆的包络。圆的包络表示笛卡尔坐标系中的“y = 0”。
这是我期望输出的示例:
(来源:slikomat.com)
在此先致谢!
你需要在圆的半径上加上“噪声”,大致在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');
示例图如下所示:
根据我之前对 的回答:
%// 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
更简单的方法是使用 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'))
我有一些带有时标的随机信号(例如 sin
信号)。
t=0:0.1:2*pi
y=sin(t)
plot(t,y)
现在我想在这个圆上画这个信号。所以时间向量实际上变成了圆的包络。圆的包络表示笛卡尔坐标系中的“y = 0”。
这是我期望输出的示例:
(来源:slikomat.com)
在此先致谢!
你需要在圆的半径上加上“噪声”,大致在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');
示例图如下所示:
根据我之前对
%// 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
更简单的方法是使用 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'))