This question already has an answer here:

I dont understand one thing when I use the function fft(x,N) in matlab, where x is the signal which I want to calculate the fourier transform and N is the number of samples. What I dont understant when I represent the fft in a graph is the amplitude. Suppose that x is a cosine wave and N=1024, why the amplitude of the two deltas are different from PI? In concrete, why N affect the amplitude in fft? What have to do with that? I hope you can understand me. Thanks in advance


marked as duplicate by Peter K. Mar 19 '18 at 12:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Have you read the Matlab docs (doc fft)? They give exactly the formula used for the DFT; from that you can directly infer the amplitude! $\endgroup$ – Marcus Müller Mar 19 '18 at 9:26
  • $\begingroup$ I read it, that's why I am asking this. The doc says that n is the length, and says that If X is a vector and the length of X is less than n, then X is padded with trailing zeros to length n. Also, it says that :If X is a vector and the length of X is greater than n, then X is truncated to length n. But I dont get it with that information, they are referring to the length, not amplitude $\endgroup$ – victor26567 Mar 19 '18 at 9:44
  • $\begingroup$ I was refering to the formulas in de.mathworks.com/help/matlab/ref/fft.html#buuutyt-5 ; your problem has nothing to do with zeropadding. Simply insert your cosine into that $Y(k)$ and test what the result is – it's never $\pi$ (I must admit I'm not even sure where your idea comes from it should be $\pi$ – you might be confusing this with the continuous Fourier transform, maybe?) $\endgroup$ – Marcus Müller Mar 19 '18 at 9:46
  • $\begingroup$ so,in $Y(k)$ the amplitude is multiplied by $W$ ? $\endgroup$ – victor26567 Mar 19 '18 at 9:50
  • $\begingroup$ yes, the pi comes from the fourier transform in continous time $\endgroup$ – victor26567 Mar 19 '18 at 9:51