DSPRelated.com
Forums

Matlab FFT

Started by shoma April 14, 2006
For the question below i was looking for help since some parts of it i
don't get. 

For part A I import the data in matlab and then plot it using the plot
function. i get my x-axis as the number of samples which is 16384 and
then the y is the values of the signal. but i dono if i am drawing it
correct. should it be in any diff format in terms of x-axis. maybe
freq?

For part B i found the Fs by deviding the 80ms/16384. Which should be
right.

For part C i get the dc componmet which is the mean of the graph from
matlab. although if my FFT graph is corrct in the next part the X(0)
will be my dc componemet.

For part D i use FFT(ABS(signal)) get a real values but i need to confirm
this.

Can you please tell me what i should do here? and show me the steps
ONE BY ONE in matlab. i will need full answers and not walkthorughs
since i have an idea how to do it but i know it is not right.

files or graphs can be sent using www.yousentit.com or a link.

the signal file can be found here:
http://s59.yousendit.com/d.aspx?id=2QOB20YI5KNOG262E4UMLJAH8J

thanx a bunch in advance. i am so lost in this one :(


Question:

The attached file called �signal� is a list of 16384 real numbers. These
numbers represent the result of sampling an audio signal for 80
milliseconds. None of the components of that signal have a frequencies
above the Nyquist threshold for the sampling rate used.

(a) Plot the signal.

(b) What was the sampling frequency?

(c) What is the D.C. component of the signal?

(d) Use the fft function and the plotting facilities of MATLAB to
generate
a graph of that part of the power spectrum of this signal which contains
meaningful data.

(e) Estimate the frequencies (in kHz), amplitudes and phases (in radians)
of the principal components of the signal.

(f) Suppose a sinusoid of frequency 256kHz were added to the original
signal in the previous question before sampling. Exactly how would this
change the graph in (2d) above?

shoma wrote:
> For the question below i was looking for help since some parts of it i > don't get. > > For part A I import the data in matlab and then plot it using the plot > function. i get my x-axis as the number of samples which is 16384 and > then the y is the values of the signal. but i dono if i am drawing it > correct. should it be in any diff format in terms of x-axis. maybe > freq? > > For part B i found the Fs by deviding the 80ms/16384. Which should be > right. > > For part C i get the dc componmet which is the mean of the graph from > matlab. although if my FFT graph is corrct in the next part the X(0) > will be my dc componemet. > > For part D i use FFT(ABS(signal)) get a real values but i need to confirm > this. > > Can you please tell me what i should do here? and show me the steps > ONE BY ONE in matlab. i will need full answers and not walkthorughs > since i have an idea how to do it but i know it is not right. > > files or graphs can be sent using www.yousentit.com or a link. > > the signal file can be found here: > http://s59.yousendit.com/d.aspx?id=2QOB20YI5KNOG262E4UMLJAH8J > > thanx a bunch in advance. i am so lost in this one :( > > > Question: > > The attached file called "signal" is a list of 16384 real numbers. These > numbers represent the result of sampling an audio signal for 80 > milliseconds. None of the components of that signal have a frequencies > above the Nyquist threshold for the sampling rate used. > > (a) Plot the signal. > > (b) What was the sampling frequency? > > (c) What is the D.C. component of the signal? > > (d) Use the fft function and the plotting facilities of MATLAB to > generate > a graph of that part of the power spectrum of this signal which contains > meaningful data. > > (e) Estimate the frequencies (in kHz), amplitudes and phases (in radians) > of the principal components of the signal. > > (f) Suppose a sinusoid of frequency 256kHz were added to the original > signal in the previous question before sampling. Exactly how would this > change the graph in (2d) above?
When I was in college, my price for doing other people's homework was a six pack. What are you offering? John
> >shoma wrote: >> For the question below i was looking for help since some parts of it i >> don't get. >> >> For part A I import the data in matlab and then plot it using the plot >> function. i get my x-axis as the number of samples which is 16384 and >> then the y is the values of the signal. but i dono if i am drawing it >> correct. should it be in any diff format in terms of x-axis. maybe >> freq? >> >> For part B i found the Fs by deviding the 80ms/16384. Which should be >> right. >> >> For part C i get the dc componmet which is the mean of the graph from >> matlab. although if my FFT graph is corrct in the next part the X(0) >> will be my dc componemet. >> >> For part D i use FFT(ABS(signal)) get a real values but i need to
confirm
>> this. >> >> Can you please tell me what i should do here? and show me the steps >> ONE BY ONE in matlab. i will need full answers and not walkthorughs >> since i have an idea how to do it but i know it is not right. >> >> files or graphs can be sent using www.yousentit.com or a link. >> >> the signal file can be found here: >> http://s59.yousendit.com/d.aspx?id=2QOB20YI5KNOG262E4UMLJAH8J >> >> thanx a bunch in advance. i am so lost in this one :( >> >> >> Question: >> >> The attached file called "signal" is a list of 16384 real numbers.
These
>> numbers represent the result of sampling an audio signal for 80 >> milliseconds. None of the components of that signal have a frequencies >> above the Nyquist threshold for the sampling rate used. >> >> (a) Plot the signal. >> >> (b) What was the sampling frequency? >> >> (c) What is the D.C. component of the signal? >> >> (d) Use the fft function and the plotting facilities of MATLAB to >> generate >> a graph of that part of the power spectrum of this signal which
contains
>> meaningful data. >> >> (e) Estimate the frequencies (in kHz), amplitudes and phases (in
radians)
>> of the principal components of the signal. >> >> (f) Suppose a sinusoid of frequency 256kHz were added to the original >> signal in the previous question before sampling. Exactly how would
this
>> change the graph in (2d) above? > >When I was in college, my price for doing other people's homework was a >six pack. What are you offering? > >John > >
lol what is it with this site :P damn man and those six packs never did anything to your brain cells :P dono man you help me do this i will provide the reward trust me :D
Is that you priced 30/50 bucks to get the detail answer on google
answers. :-O

>Is that you priced 30/50 bucks to get the detail answer on google >answers. :-O
:-(
shoma skrev:
> For the question below i was looking for help since some parts of it i > don't get.
As a matter of principle, people around here don't do homework assignments. We like to make sure our future prospective colleagues actually know their job. Would you like to fly with an aeroplane where the co-pilot's main qualification is that he saw "Top Gun" a few times, and have picked up a little bit of terminology? However, you have made an effort, and I am bored. I'll meet you half-way and look over what you have done, and give some general hints about what to do next.
> For part A I import the data in matlab and then plot it using the plot > function. i get my x-axis as the number of samples which is 16384 and > then the y is the values of the signal. but i dono if i am drawing it > correct. should it be in any diff format in terms of x-axis. maybe > freq?
I usually do it like this: N = length(x); T = 1; % Insert sampling period here fv = [0:N-1]/(N*T); plot(fv, abs(fft(x))) Then the frequency axis comes out right. It is up to you to find out why...
> For part B i found the Fs by deviding the 80ms/16384. Which should be > right.
Haven't looked at the data; I hope you are right.
> For part C i get the dc componmet which is the mean of the graph from > matlab. although if my FFT graph is corrct in the next part the X(0) > will be my dc componemet.
If you compute X as X = fft(x); then yes.
> For part D i use FFT(ABS(signal)) get a real values but i need to confirm > this.
No. The power spectrum P is computed as P= abs(fft(x)).^2;
> Can you please tell me what i should do here? and show me the steps > ONE BY ONE in matlab. i will need full answers and not walkthorughs > since i have an idea how to do it but i know it is not right. > > files or graphs can be sent using www.yousentit.com or a link. > > the signal file can be found here: > http://s59.yousendit.com/d.aspx?id=2QOB20YI5KNOG262E4UMLJAH8J > > thanx a bunch in advance. i am so lost in this one :( > > > Question: > > The attached file called "signal" is a list of 16384 real numbers. These > numbers represent the result of sampling an audio signal for 80 > milliseconds. None of the components of that signal have a frequencies > above the Nyquist threshold for the sampling rate used. > > (a) Plot the signal. > > (b) What was the sampling frequency? > > (c) What is the D.C. component of the signal? > > (d) Use the fft function and the plotting facilities of MATLAB to > generate > a graph of that part of the power spectrum of this signal which contains > meaningful data. > > (e) Estimate the frequencies (in kHz), amplitudes and phases (in radians) > of the principal components of the signal.
A bit dodgy, this one. "Principal components of a signal" is not part of the standard terminology. "Dominant features in the spectrum" might be abetter term, although I am only guessing. anyway, use the function CART2POL to transform your spectrum (NOT the power spectrum) to polar format, and plot the magnitude and phase. I'll guess there are peaks somewhere. Read the magnitude and phase for each peak.
> (f) Suppose a sinusoid of frequency 256kHz were added to the original > signal in the previous question before sampling. Exactly how would this > change the graph in (2d) above?
Take a hard-copy of the plot and sketch the change you think will happen. Then add the sinusiod as specified to the data, compute the spectrum and compare with what you sketched beforehand. Rune
shoma wrote:
> For the question below i was looking for help since some parts of it i > don't get. > > For part A I import the data in matlab and then plot it using the plot > function. i get my x-axis as the number of samples which is 16384 and > then the y is the values of the signal. but i dono if i am drawing it > correct. should it be in any diff format in terms of x-axis. maybe > freq? > > For part B i found the Fs by deviding the 80ms/16384. Which should be > right. > > For part C i get the dc componmet which is the mean of the graph from > matlab. although if my FFT graph is corrct in the next part the X(0) > will be my dc componemet. > > For part D i use FFT(ABS(signal)) get a real values but i need to confirm > this.
You can't discard the sign and get correct results. Contemplate the Fourier transform in greater detail; you may in that way receive enlightenment. ... Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
> >shoma skrev: >> For the question below i was looking for help since some parts of it i >> don't get. > >As a matter of principle, people around here don't do homework >assignments. We like to make sure our future prospective >colleagues actually know their job. Would you like to fly >with an aeroplane where the co-pilot's main qualification >is that he saw "Top Gun" a few times, and have picked up >a little bit of terminology? > >However, you have made an effort, and I am bored. >I'll meet you half-way and look over what you have done, and >give some general hints about what to do next. > >> For part A I import the data in matlab and then plot it using the plot >> function. i get my x-axis as the number of samples which is 16384 and >> then the y is the values of the signal. but i dono if i am drawing it >> correct. should it be in any diff format in terms of x-axis. maybe >> freq? > >I usually do it like this: > >N = length(x); >T = 1; % Insert sampling period here >fv = [0:N-1]/(N*T); >plot(fv, abs(fft(x))) > >Then the frequency axis comes out right. It is up to you to >find out why... > >> For part B i found the Fs by deviding the 80ms/16384. Which should be >> right. > >Haven't looked at the data; I hope you are right. > >> For part C i get the dc componmet which is the mean of the graph from >> matlab. although if my FFT graph is corrct in the next part the X(0) >> will be my dc componemet. > >If you compute X as > >X = fft(x); > >then yes. > >> For part D i use FFT(ABS(signal)) get a real values but i need to
confirm
>> this. > >No. The power spectrum P is computed as > >P= abs(fft(x)).^2; > >> Can you please tell me what i should do here? and show me the steps >> ONE BY ONE in matlab. i will need full answers and not walkthorughs >> since i have an idea how to do it but i know it is not right. >> >> files or graphs can be sent using www.yousentit.com or a link. >> >> the signal file can be found here: >> http://s59.yousendit.com/d.aspx?id=2QOB20YI5KNOG262E4UMLJAH8J >> >> thanx a bunch in advance. i am so lost in this one :( >> >> >> Question: >> >> The attached file called "signal" is a list of 16384 real numbers.
These
>> numbers represent the result of sampling an audio signal for 80 >> milliseconds. None of the components of that signal have a frequencies >> above the Nyquist threshold for the sampling rate used. >> >> (a) Plot the signal. >> >> (b) What was the sampling frequency? >> >> (c) What is the D.C. component of the signal? >> >> (d) Use the fft function and the plotting facilities of MATLAB to >> generate >> a graph of that part of the power spectrum of this signal which
contains
>> meaningful data. >> >> (e) Estimate the frequencies (in kHz), amplitudes and phases (in
radians)
>> of the principal components of the signal. > >A bit dodgy, this one. "Principal components of a signal" is not part >of the standard terminology. "Dominant features in the spectrum" >might be abetter term, although I am only guessing. > >anyway, use the function CART2POL to transform your spectrum (NOT the >power spectrum) to polar format, and plot the magnitude and phase. >I'll guess there are peaks somewhere. Read the magnitude and phase >for each peak. > >> (f) Suppose a sinusoid of frequency 256kHz were added to the original >> signal in the previous question before sampling. Exactly how would
this
>> change the graph in (2d) above? > >Take a hard-copy of the plot and sketch the change you think will >happen. >Then add the sinusiod as specified to the data, compute the spectrum >and compare with what you sketched beforehand. > >Rune > >
the rest i get and thanx you very much but this one
>anyway, use the function CART2POL to transform your spectrum (NOT the >power spectrum) to polar format, and plot the magnitude and phase. >I'll guess there are peaks somewhere. Read the magnitude and phase >for each peak.
is not clear. can u tell me what you mean. and btw i am not an eng i took this course for fun but the matlab part is not fun at all :(
shoma skrev:
> >anyway, use the function CART2POL to transform your spectrum (NOT the > >power spectrum) to polar format, and plot the magnitude and phase. > >I'll guess there are peaks somewhere. Read the magnitude and phase > >for each peak. > > is not clear. can u tell me what you mean.
First, in the exercise you have dealt with both the "norma" spectrum and the power spectrum. The difference is that only the "normal" spectrum contains phase information. Since you have been asked to find both magnitude and phase, using the power spectrum is out of the question. I assume you are familiar with complex numbers. Complex numbers can be formulated in two ways, either on carthesian form, as z = x + i*y where x is the real part, y is the imaginary part and i = sqrt(-1), or on polar form as z = r*exp(i*phi) where r is the magnitude and phi is the phase angle. CART2POL (use lowercase spelling in matlab) is a matlab function that converts from carthesian format to polar format.
> and btw i am not an eng i took this course for fun but the matlab part is > not fun at all :(
Matlab is very efficient as a pedagogical tool, but it takes a bit of getting used to, Rune
> >shoma skrev: >> >anyway, use the function CART2POL to transform your spectrum (NOT the >> >power spectrum) to polar format, and plot the magnitude and phase. >> >I'll guess there are peaks somewhere. Read the magnitude and phase >> >for each peak. >> >> is not clear. can u tell me what you mean. > >First, in the exercise you have dealt with both the "norma" spectrum >and the power spectrum. The difference is that only the "normal" >spectrum contains phase information. Since you have been asked to >find both magnitude and phase, using the power spectrum is out of the >question. > >I assume you are familiar with complex numbers. Complex numbers >can be formulated in two ways, either on carthesian form, as > >z = x + i*y > >where x is the real part, y is the imaginary part and i = sqrt(-1), or >on >polar form as > >z = r*exp(i*phi) > >where r is the magnitude and phi is the phase angle. > >CART2POL (use lowercase spelling in matlab) is a matlab function >that converts from carthesian format to polar format. > >> and btw i am not an eng i took this course for fun but the matlab part
is
>> not fun at all :( > >Matlab is very efficient as a pedagogical tool, but it takes a >bit of getting used to, > >Rune >
i understand that but how would i tell matlab to do that?
>