what does sin(pi*[-Fs:1/Fs:Fs] )mean?

19 views (last 30 days)
Shradha Sharma
Shradha Sharma on 27 Nov 2012
I am trying a code. I am unable to figure out this line. Please help asap!!

Answers (3)

Akiva Gordon
Akiva Gordon on 27 Nov 2012
Let's break it down into smaller chunks:
This line creates a vector from -Fs to Fs with increments of 1/Fs
vector = -Fs:1/Fs:Fs
Now multiply each element of that vector by pi and store that in the vector "theta"
theta = pi*vector
Finally, take the sine of each element in the theta vector
sin(theta)

Wayne King
Wayne King on 27 Nov 2012
It's just a sine, but I'm not sure why they have coded up that way. It has a period of 2 so depending on what Fs is you can tell how many samples constitute 1 period.
For example:
Fs = 1000;
y = sin(pi*[-Fs:1/Fs:Fs]);
It has a period of 2000 samples
plot(y(1:2000));
The fact that it looks like they are using a frequency variable for the sine makes me think they really want a sinc() function, which is not the same.
  2 Comments
Image Analyst
Image Analyst on 27 Nov 2012
Shradha, it probably would have been a little easier to understand if they'd used spaces and parentheses, like this:
-Fs : (1/Fx) : Fs
It's basically (startingValue) : (stepValue) : (endingValue). Of course an alternative is the linspace() function:
numberOfSteps = 2 * (Fs ^ 2);
vector = linspace(-Fs, Fs, numberOfSteps);
used mainly when you want to specify the number of steps instead of the step spacing. You can use whichever style suits you.
Wayne, I don't see how they might have wanted the sinc. It looks like a pretty standard sine to me, just like in Wikipedia: http://en.wikipedia.org/wiki/Sine_wave sine(omega*t) where omega is 2*pi*frequency.
Wayne King
Wayne King on 27 Nov 2012
The fact that they are using a notation usually reserved for a frequency variable, Fs, made me question whether they were trying to approximate the Fourier transform a rectangle in time (a sinc in the Fourier domain). Even though they are using a conventional DT, 1/FS, to have a time vector run from -Fs to Fs looked a bit unconventional to me.

Sign in to comment.


Azzi Abdelmalek
Azzi Abdelmalek on 27 Nov 2012
v=[-Fs:1/Fs:Fs]
%is a vector with element from -Fs to Fs with step = 1/Fs

Categories

Find more on Mathematics in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!