Home csc (cosecant) periodic equation and unexpected results
Reply: 1

csc (cosecant) periodic equation and unexpected results

Rick T
1#
Rick T Published in 2018-01-12 20:51:25Z

I can plot 1 (co-secant) every second over 2 seconds and it looks fine (the top plot). But when I plot the frequency of 100 csc (co-secant) signals I would expect / want 100 co-secant signals that are just repeating the same signal much like plotting y=.8*sin(100*t) would do but that doesn't occur what am I doing wrong? See code and plot below.

clear, clc
fs=8000
len_of_sig=2; %length of signal in seconds
t=linspace(0,2*pi*len_of_sig,fs*len_of_sig);
y_a=0.01*csc(1*t);
y_a(y_a >=1) = 1; %used to limit amplitude
y_a(y_a <=-1) = -1;

y_b=0.01*csc(100*t);
y_b(y_b >=1) = 1;
y_b(y_b <=-1) = -1;

t2=t./(2*pi); %converts time in radians to seconds
subplot(2,1,1);plot(t2(1:end),y_a(1:end));
subplot(2,1,2);plot(t2(1:end),y_b(1:end));

Ps: I'm using octave 4.0 which is like matlab

gnovice
2#
gnovice Reply to 2018-01-13 04:19:20Z

What you're seeing in the second subplot is the result of reduced sampling per cycle. You are increasing the frequency of y_b relative to y_a by a factor of 100, but still using the same vector of time points t, meaning you have 1/100th the number of points per cycle in y_b. These fewer points per cycle fall at slightly different offsets to the discontinuities, giving you the pattern above.

You can fix this by using an upsampled time vector for y_b:

t_up = linspace(0, 2*pi*len_of_sig, 100*fs*len_of_sig);
y_b = 0.01*csc(100*t_up);
y_b(y_b >= 1) = 1;
y_b(y_b <= -1) = -1;
subplot(2, 1, 2); plot(t_up./(2*pi), y_b);

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.299015 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO