Results 1 to 8 of 8

Math Help - matlab fft

  1. #1
    Member
    Joined
    Dec 2008
    Posts
    86

    matlab fft

    dsa
    Last edited by qwerty321; January 13th 2009 at 11:13 PM.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Member
    Joined
    May 2006
    Posts
    244
    Quote Originally Posted by qwerty321 View Post
    Hello



    can someone help me with this assignement?

    Find in MATLAB the frequency components in the following
    signal:


    y
    (t) = (cos(300πt) + sin(500πt))3

    Use


    .^3 (with the dot) in MATLAB to calculate the third power.

    how do I do this?



    thank you
    try this:

    Code:
    fs=2000; %sampling frequency dt=1/fs; %sampling interval t=0:dt:1-dt/2;
    y=(cos(300*pi*t)+cos(500*pi*t)).^3; %1 seconds worth ofsignal
    sp=fft(y); %fft spp=abs(sp); %absolute value of frequency component %(you could square this as well to get something like a power) df=1; %frequency resolution (in Hz) f=0:df:999; %frequency scale for spectrum spp=spp(1:1000); %cut out the part of spectrum below Nyquist frequenct plot(f,spp); %plot
    This is not normalised (since the normalisation is different for different FFT implementations). It also gives an absolute amplitude plot. I would prefere a dB plot re arbitary myself.
    Last edited by Constatine11; January 13th 2009 at 09:00 AM.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Member
    Joined
    Dec 2008
    Posts
    86
    ok..someone told me I could also use this:
    Y = fft(y,512);
    Pyy = Y.* conj(Y)/512;
    f = 20000*(0:256)/512;
    plot(f,Pyy(1:257))
    title('Frequency content of y')
    xlabel('frequency (Hz)')

    can you expalin to me what each one does?

    y is a function
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Member
    Joined
    May 2006
    Posts
    244
    Quote Originally Posted by qwerty321 View Post
    ok..someone told me I could also use this:
    Y = fft(y,512);
    Pyy = Y.* conj(Y)/512;
    f = 20000*(0:256)/512;
    plot(f,Pyy(1:257))
    title('Frequency content of y')

    xlabel('frequency (Hz)')

    can you expalin to me what each one does?

    y is a function
    Have you tried executing this code?

    .
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Member
    Joined
    Dec 2008
    Posts
    86
    well in fact this code was use to find the frequency components of a signal buried inside a noisy time domain signal using the fft function in MATLAB.
    the assignement says :
    Using the same technique, find in MATLAB the frequency components in the following
    signal:
    y(t) = (cos(300πt) + sin(500πt))^3

    so i think i need to use the same code
    thank you
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Member
    Joined
    Dec 2008
    Posts
    86
    ur code does not work anyhow
    Undefined function or variable 'dt'.
    why?
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Member
    Joined
    Dec 2008
    Posts
    86
    btw is there a command that can clear the command window?becauase each time i want to write something new i have to exit then reenter it
    Follow Math Help Forum on Facebook and Google+

  8. #8
    Member
    Joined
    May 2006
    Posts
    244
    Quote Originally Posted by qwerty321 View Post
    ur code does not work anyhow
    Undefined function or variable 'dt'.
    why?
    Because of an error in copying it over, the previous line's comment where it says:

    "dt=1/fs;"

    should have been on a new line as a command.

    .
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Matlab help
    Posted in the Math Software Forum
    Replies: 1
    Last Post: February 11th 2010, 02:59 AM
  2. Matlab FFT Help
    Posted in the Math Software Forum
    Replies: 0
    Last Post: June 3rd 2009, 12:48 PM
  3. help about ODE in matlab
    Posted in the Math Software Forum
    Replies: 1
    Last Post: May 31st 2009, 03:10 AM
  4. Matlab Please help me
    Posted in the Math Software Forum
    Replies: 8
    Last Post: November 10th 2008, 04:40 PM
  5. Matlab
    Posted in the Calculus Forum
    Replies: 3
    Last Post: August 20th 2008, 10:39 PM

Search Tags


/mathhelpforum @mathhelpforum