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

조회 수: 21 (최근 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