我有一些带有时间刻度的随机信号(例如sin
信号)。
t=0:0.1:2*pi
y=sin(t)
plot(t,y)
现在我想在这个圆圈上绘制这个信号。所以时间向量实际上变成了圆的包络。圆的包络在笛卡尔坐标系中表示“y = 0”。
以下是我期望输出结果的示例:
The example picture of what we want is on this link. http://www4.slikomat.com/13/0623/m4r-201506.jpg
先谢谢!
答案 0 :(得分:2)
根据我之前对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
答案 1 :(得分:1)
您需要将“噪音”添加到圆的半径,大约在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');
示例图如下:
答案 2 :(得分:0)
更简单的方法是使用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'))