How do I calculate the FFT or PSD of embedded.fi objects in Fixed-Point Toolbox 2.2 (R2008a)?

4 views (last 30 days)
I have a model which generates and uses some embedded.fi objects. I want to use these objects with the FFT and PWELCH functions. However, I am unable to use these objects for PSD analysis.
For example, I have data in my_fi (an embedded.fi object). When I execute the following:
[Pxx,f] = pwelch(my_fi,hann(1*4096),1*2048,1*4096,fsamp1);
I get the following error messages:
??? Undefined function or method 'fft' for input arguments of type 'embedded.fi'.
Error in ==> computeDFT>computeDFTviaFFT at 68
Xx = fft(xw,nfft);
Error in ==> computeDFT at 47
[Xx,f] = computeDFTviaFFT(xin,nx,nfft,Fs);
Error in ==> computeperiodogram at 71
[Xx,f] = computeDFT(xw,nfft,Fs);
Error in ==> welch at 67
[Sxxk,w] = computeperiodogram(x(xStart(i):xEnd(i)),win,...
Error in ==> pwelch at 121
[varargout{1:nargout}] = welch(x,esttype,varargin{:});
Error in ==> thdpn_for_dsp at 20
[Pxx,f] = pwelch(out_test6,hann(1*4096),1*2048,1*4096,fsamp1);

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 7 Dec 2011
FFT and PWELCH cannot be used directly on FI objects that belong to the Fixed-Point Toolbox. These functions are designed to act on 'Double' data type vectors and since FI objects are specialized objects that contain different properties, these functions cannot be directly used on 'my-fi' object. We will need to execute these functions on the 'data' contained in this FI object for it to work correctly.
To view the PSD of the data contained in the embedded.fi object, execute the following:
[Pxx,f] = pwelch(my_fi.data,hann(1*4096),1*2048,1*4096,fsamp1);
Note how we have used these functions on the 'data' field of the 'my-fi' object, instead of using the object itself.
You may additionally execute the following commands before executing the above mentioned statement:
F = fipref;
F. DataTypeOverride = TrueDoubles;
This above optional statement ensures that the datatype of the data contained in the FI object is of type 'Double'.

More Answers (0)

Products


Release

R2008a

Community Treasure Hunt

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

Start Hunting!