01-20-2013 10:48 AM
Hello,
I am trying to figure out a problem in which I am supposed to use a MathScript Node to evaluate the given expression in the range t>=0, t<=3.
The book I'm using says to input: y(t)=(4/pi)*(sin(2*pi*t)+(sin(6*pi*t)/3)+(sin(10*pi*t)/5)+(sin(14*pi*t)/7)), and that this formula should create a square wave.
I have put in the following code:
delta_t=1/f_s
start=0
step=delta_t
stop=(N-1)*delta_t
t=start:step:stop
t>=0
t<=3
y=4*(sin(2*pi*t)+(sin(6*pi*t)/3)+(sin(10*pi*t)/5)+(sin(14*pi*t)/7))/pi
However, the result I am getting is not a square wave at all. I have attached the VI (I am using N=500 and f_s=10000).
Any ideas?
-Jill
01-21-2013 11:21 AM
Hello Jill,
Thanks for providing the code you're using- the signal you are currently seeing is because you are sampling the waveform quite fast compared to the signal frequency and you don't have a full period of the waveform to display; increasing the number of samples generated gives a waveform something like this:
Which appears to be a square wave built with a sin function as you have described. With the values you specified (N=500), you're only seeing part of that initial curve (T=0 to T=0.05, or about 1/20th of the waveform's apparent fundamental period.)
Regards,