does function "fft" support int16 data type?

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

Answers (2)

David Goodmanson
David Goodmanson on 24 Aug 2017
Edited: David Goodmanson on 24 Aug 2017
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 Comments

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,
@Big dream: Please post a working example.
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.

Sign in to comment.

I see... Thank you so much David, really appreciate your help!

Products

Tags

Asked:

on 24 Aug 2017

Commented:

on 20 Oct 2017

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!