clear all; close all; N=256; 进行256点FFT t = 0:0.001:0.6; 采样频率1Khz x = sin(2*pi*50*t)+sin(2*pi*120*t); 原始信号包含50hz和120hz两种信号 x=x/2; 进行归一化处理 subplot(3,1,1); plot(1000*t,x); title('原始数据')
, w5 n1 Q# r) e# x" P. a! cy= (x + 2 * rand(size(t)) -1)/2; 增加噪声信号,幅值正负1,并归一化处理 subplot(3,1,2); plot(1000*t,y); title('增加噪声后的数据')
+ n' N* `5 d/ s H X2 X# D+ zy2=round(y*2^15); 对数据取整,并进行16bit量化 fid=fopen('Data_input.txt','w+'); 把原始数据存入文件Data_input.txt fprintf(fid,'%g\r\n',y2); fclose(fid); ! R+ Q$ s( ]% R
[Y, exp_out]= fft256_model(y2(1:256),N,0); 调用fft256_model
& v; V$ r- X" E- v6 A9 o- E1 x把转换后的数据分别存入fft_real_output.txt和fft_imag_output.txt fid=fopen('fft_real_output.txt','w+'); fprintf(fid,'%g\r\n',real(Y)); fclose(fid);
+ e% S$ z$ B. e$ J* r. Vfid=fopen('fft_imag_output.txt','w+'); fprintf(fid,'%g\r\n',imag(Y)); fclose(fid); - Q4 I* ~8 l' Z. V/ l& j- x
Pyy = Y.* conj(Y) ; f = 1000*(0:128)/256; subplot(3,1,3); plot(f,Pyy(1:129)) title('Quantus中IPcore函数转换的结果') |