Matlab: Fourier transforms in numeric form

Discussion in 'Homework Help' started by tquiva, Sep 5, 2011.

  1. tquiva

    Thread Starter Member

    Oct 19, 2010
    176
    1
    I have the following problem:

    [​IMG]

    I was able to do part (a), but got stuck when I got to part (b).
    So far, my code is:

    Code ( (Unknown Language)):
    1. n=7; star=-2*n:2*n;
    2. bbox=(abs(star)<=n); bbox=bbox/sqrt(sum(bbox.^2));
    3. cox=cos(pi*star/(2*n+1)).*bbox; cox=cox/sqrt(sum(cox.^2));
    4. c2ox=cos(pi*star/(2*n+1)).*cox; c2ox=c2ox/sqrt(sum(c2ox.^2));
    5. % Plots for n=7
    6. subplot(331),plot(star,bbox),xlabel('*'),ylabel('bbox(*)'),title('bbox(*) for n=7')
    7. subplot(332),plot(star,cox),xlabel('*'),ylabel('cox(*)'),title('cox(*) for n=7')
    8. subplot(333),plot(star,cox),xlabel('*'),ylabel('cox(*)'),title('cox(*) for n=7')
    9.  
    10. % Decrease n by 1
    11. n=6; star=-2*n:2*n;
    12. bbox=(abs(star)<=n); bbox=bbox/sqrt(sum(bbox.^2));
    13. cox=cos(pi*star/(2*n+1)).*bbox; cox=cox/sqrt(sum(cox.^2));
    14. c2ox=cos(pi*star/(2*n+1)).*cox; c2ox=c2ox/sqrt(sum(c2ox.^2));
    15. % Plots for n=6
    16. subplot(334),plot(star,bbox),xlabel('*'),ylabel('bbox(*)'),title('bbox(*) for n=6')
    17. subplot(335),plot(star,cox),xlabel('*'),ylabel('cox(*)'),title('cox(*) for n=6')
    18. subplot(336),plot(star,cox),xlabel('*'),ylabel('cox(*)'),title('cox(*) for n=6')
    19.  
    20. % Increase n by 1
    21. n=8; star=-2*n:2*n;
    22. bbox=(abs(star)<=n); bbox=bbox/sqrt(sum(bbox.^2));
    23. cox=cos(pi*star/(2*n+1)).*bbox; cox=cox/sqrt(sum(cox.^2));
    24. c2ox=cos(pi*star/(2*n+1)).*cox; c2ox=c2ox/sqrt(sum(c2ox.^2));
    25. % Plots for n=8
    26. subplot(337),plot(star,bbox),xlabel('*'),ylabel('bbox(*)'),title('bbox(*) for n=8')
    27. subplot(338),plot(star,cox),xlabel('*'),ylabel('cox(*)'),title('cox(*) for n=8')
    28. subplot(339),plot(star,cox),xlabel('*'),ylabel('cox(*)'),title('cox(*) for n=8')
    Then for part (b), I tried:

    Code ( (Unknown Language)):
    1. n=7; star=-2*n:2*n;
    2. bbox=(abs(star)<=n); bbox=bbox/sqrt(sum(bbox.^2));
    3. cox=cos(pi*star/(2*n+1)).*bbox; cox=cox/sqrt(sum(cox.^2));
    4. c2ox=cos(pi*star/(2*n+1)).*cox; c2ox=c2ox/sqrt(sum(c2ox.^2));
    5.  
    6. fourier(bbox)
    but I received an error that said:

    ??? Undefined function or method 'fourier' for input
    arguments of type 'double'.

    Is there another way to do this? I tried googling other methods but I can't find any, so if anyone could please help, I greatly appreciate it.
     
  2. guitarguy12387

    Active Member

    Apr 10, 2008
    359
    12
    You probably meant 'fft' not fourier.
     
  3. tquiva

    Thread Starter Member

    Oct 19, 2010
    176
    1
    Thank you! It works now. But now, I'm not too sure of what the problem means by "closely approximate."

    On Matlab, I entered fft(bbox), and obtain a matrix of values. Is there some sort of command on matlab that'll "approximate" the fourier transform?
     
  4. Georacer

    Moderator

    Nov 25, 2009
    5,142
    1,266
    From what I understand the exercise asks you to use the Symbolic Math package of Matlab (not included in basic editions) to calculate the Fourier sequences through their mathematical formula, based on their given expressions. Not an easy task, as the Symbolic Math package is a bit stiff in my opinion.

    Then in (c), you are asked to go back to the original signal, based on the fourier sequences found in (b), again using Symbolic Math.

    I haven't done a fourier transformation by hand in years, so I can't be of much help in the actual solving. I suggest using the standard formula found in all the textbooks.
     
Loading...