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

12 次查看(过去 30 天)
Shradha Sharma
Shradha Sharma 2012-11-27
I am trying a code. I am unable to figure out this line. Please help asap!!

回答(3 个)

Akiva Gordon
Akiva Gordon 2012-11-27
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 2012-11-27
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 个评论
Image Analyst
Image Analyst 2012-11-27
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 2012-11-27
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.

请先登录,再进行评论。


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

类别

Help CenterFile Exchange 中查找有关 Mathematics 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by