does function "fft" support int16 data type?
Mostrar comentarios más antiguos
Hi,
I have MATLAB R2016b. When I was using "fft" function, I got an error message : "Undefined function 'fft' for input arguments of type 'int16'"
The error message disappears if I convert my data to double.
However, I am a bit confused that when I looked at "fft" help page, it does say that "int16" is supported for the input.
Can anyone please help me understand this?
thanks, L
Respuestas (2)
David Goodmanson
el 24 de Ag. de 2017
Editada: David Goodmanson
el 24 de Ag. de 2017
0 votos
Hello L,
2016b works for uint16 but not int16 on input. 2017a works for both int16 and uint16. Presumably the documentation page refers to the latest version of Matlab.
Of course in the cases that work, the output is an array of doubles.
3 comentarios
Big dream
el 20 de Oct. de 2017
Hello David,
I've already installed MATLAB 2017a, and i used the FFT() with int16. But when i compare the result AfterIfft between using DataTest as in int16 and as double, it's shown quiet big difference. Here are the code and the result after
DataTest=(fft(InputTest,512));
%// Envelope initialisation--> Halbe Frequenzspektren
DataTest =DataTest(1:256);
%// Inverse fft (dynamic scaling)
AfterIfft=ifft(DataTest,512);
end
% Here is a result of AfterIfft
AfterIfft(204)= 600,206118497517 + 65,8572349498327i %using double
AfterIfft(204)= 509 - 54i %using int16
When i use the absolute function, the results have almost 100 gap. Do you know how FFT() works in MATLAB using difference type variable? Or maybe when i use integer as a type of variable, should i set a parameter first?
Thanks,
Jan
el 20 de Oct. de 2017
@Big dream: Please post a working example.
David Goodmanson
el 20 de Oct. de 2017
Hello Bigdream,
I think there must be something else going on. In 2017a,
a = round(100*rand(1,256)); % integer doubles
a16 = int16(a);
z = fft(a,512);
z16 = fft(a16,512);
max(abs(z-z16))
ans = 0
gives perfect agreement. Of course
a = (100*rand(1,256)); % doubles but not integers
a16 = int16(a);
etc.
doesn't work since int16 does rounding and the two input arrays are not the same.
Li Zhang
el 24 de Ag. de 2017
0 votos
Categorías
Más información sobre Multirate Signal Processing en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!