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
回答(2 个)
David Goodmanson
2017-8-24
编辑:David Goodmanson
2017-8-24
0 个投票
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 个评论
Big dream
2017-10-20
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
2017-10-20
@Big dream: Please post a working example.
David Goodmanson
2017-10-20
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Multirate Signal Processing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!