Reputation: 23
I have some random signal (for example sin
signal) with the time scale.
t=0:0.1:2*pi
y=sin(t)
plot(t,y)
Now I want to draw this signal on this circle. So the time vector actually becomes an envelope of the circle. Envelope of the circle represents "y = 0" in cartesian coordinate system.
Here is an example of what I expect the output to look like:
(source: slikomat.com)
Thank in advanced!
Upvotes: 1
Views: 846
Reputation: 112699
A simpler way is to use polar
:
t = linspace(0,2*pi,1000);
y = .1*sin(t*30); %// amplitude .1 and frequency 30, relative to circle
polar(t, 1+y);
If you want to remove the text generated by polar
, use
delete(findall(gca, 'type', 'text'))
Upvotes: 0
Reputation: 25232
Based on my previous answer to 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
Upvotes: 2
Reputation: 114846
You need to add "noise" to the radius of the circle, roughly around 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');
An example plot would look like:
Upvotes: 1