n = 64; % Number of points
Fs = 4; % Sampling frequency in Hz
t = (0:(n-1))/Fs; % Time vector
f = linspace(0,Fs,n); % Frequency vector
f0 = 0.2; f1 = 0.5; % Frequencies, in Hz
x0 = cos(2*pi*f0*t) + 0.55*cos(2*pi*f1*t)+1.6 ; % Time-domain signal
%x0 = complex(x0); % The textbook algorithm requires the input to be complex
y0 = fft(x0); % Frequency-domain transformation fft() is a MATLAB built-in function
% fi_fft_demo_ini_plot(t,x0,f,y0); % Plot the results from fft and time-domain signal
w0 = fi_radix2twiddles(n);
%% (1)verifying that you have correctly implemented the algorithm FFT
y = fi_m_radix2fft_algorithm1_6_2(x0, w0);
fi_fft_demo_plot(real(x0),y,y0,Fs,'Double data', ...
{'FFT Algorithm 1.6.2','Built-in FFT'});
%% (2)Identify Fixed-Point Issues
T2 = fi_m_radix2fft_fixed_types(); % Get fixed point data types declared in table
x = cast(x0,'like',T2.x);
w = cast(w0,'like',T2.w);
y2 = fi_m_radix2fft_algorithm1_6_2_typed(x,w,T2);
% y2 = fi_m_radix2fft_withscaling_typed(x,w,T2);
fi_fft_demo_plot(real(x),y2,y0,Fs,'Fixed-point data', ...
{'Fixed-point FFT Algorithm 1.6.2','Built-in FFT'});
%% (3)Use Min/Max Instrumentation to Identify Overflows
% T3 = fi_m_radix2fft_scaled_fixed_types(); % Get fixed point data types declared in table
% Create the input with a scaled double data type
% so its values will attain full range and you can identify potential overflows.
tic;
T3 = fi_m_radix2fft_fixed_types();
x_scaled_double = cast(x0,'like',T3.x);
w_scaled_double = cast(w0,'like',T3.w);
y3 = fi_m_radix2fft_withscaling_typed(x_scaled_double,w_scaled_double,T3);
fi_fft_demo_plot(real(x_scaled_double),y3,y0/n,Fs,'Fixed-point data', ...
{'Fixed-point FFT with scaling','Built-in FFT'});
disp(num2str(toc));
基于matlab的定点FFT算法实现
版权申诉
5星 · 超过95%的资源 178 浏览量
2022-01-11
14:23:50
上传
评论 5
收藏 111KB RAR 举报
smartisong
- 粉丝: 178
- 资源: 3
最新资源
- pta题库答案c语言之排序4统计工龄.zip
- pta题库答案c语言之树结构7堆中的路径.zip
- pta题库答案c语言之树结构3TreeTraversalsAgain.zip
- pta题库答案c语言之树结构2ListLeaves.zip
- pta题库答案c语言之树结构1树的同构.zip
- 基于C++实现民航飞行与地图简易管理系统可执行程序+说明+详细注释.zip
- pta题库答案c语言之复杂度1最大子列和问题.zip
- 三维装箱问题(Three-Dimensional Bin Packing Problem,3D-BPP)是一个经典的组合优化问题
- 以下是一些关于Linux线程同步的基本概念和方法.txt
- 以下是一个简化的示例,它使用pygame库来模拟烟花动画的框架.txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
- 4
- 5
- 6
前往页