fft function
25 次查看(过去 30 天)
显示 更早的评论
hi, i'm trying to figure out exactly how matlab dose fft. i understand the basic idie but i saw somwere the command y=fft(x,'symetric') if x is a vector of size 10 the resuly y is a vector of size 115. what dose the aargument 'symetric' do? any word i put insted changes the length of y vector? what is the meaning of this?
thank you,
采纳的回答
Marlies
2012-3-29
The command 'fft(x)' will compute the discrete Fourier transform (DFT) of the vector x.
By default, the number of elements in the output will be the same as the the number of elements in the input. However, I can give an (optional) second argument to explicitly define how many elements I want in my output vector.
Y = fft(x) % length(Y) == length(x)
Y = fft(x,100) % length(Y) == 100
The string 'symmetric' is not recognized by MATLAB. De fft command does not take any additional flag, specifier or alternative string-input.
However, what happens is that MATLAB is interpreting your string 'symmetric' as a vector of numbers; the ASCII-code of each character. You can see the value of the characters if you use the command 'double'
double('symmetric')
if you try to use the fft-command like you do, you'll also see a warning:
Warning: FFT length must be a non-negative integer scalar.
MATLAB is trying to determine the length of the FFT by checking the value of the second input. This gives a vector (double('symmetric')), so you get the warning that the second input should be a (non-negative, integer) scalar. And MATLAB is then taking the first number as default. In this case that is 115. So different words will indeed give different outputs, because they probably start with a different letter.
Hope this helps,
Marlies
3 个评论
Marlies
2012-3-29
Wayne, I think you are absolutely right.
Thank you.
OP, you should probably look into Waynes answer as well for a proper explanation of how MATLAB does FFT if you use the ifft command.
vandana sharma
2019-2-27
can we apply the fft command as
fresult=fft(x,y);
Actually I am trying to convert time-amplitude signal as frequency-amplitude signal.
更多回答(2 个)
Jan
2012-3-29
When I read http://www.mathworks.com/help/techdoc/ref/fft.html I do not find a 'symmetric' flag (double 'm'?).
0 个评论
Wayne King
2012-3-29
I think the OP is really thinking of the 'symmetric' flag in ifft(), not in fft().
The purpose of that flag is that often people are trying to take the inverse Fourier transform of complex-valued data (the DFT of something) that should exhibit conjugate symmetry.
The DFT of real-valued signals is conjugate symmetric.
However, because of small numerical errors just using ifft() on this data may result in a complex-valued (time domain) signal (usually the imaginary parts are close to zero, but non-zero).
The 'symmetric' flag is a simple way of saying: "I know what I'm applying the inverse Fourier transform to should be conjugate symmetric, so give me a real-valued output."
xdft = fft(randn(1e3,1));
xrec = ifft(xdft,'symmetric');
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!