| 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('原始数据')
* C# G! m, D8 k' gy= (x + 2 * rand(size(t)) -1)/2; 增加噪声信号,幅值正负1,并归一化处理 subplot(3,1,2); plot(1000*t,y); title('增加噪声后的数据') 6 [3 J& m+ O1 z+ o; x
y2=round(y*2^15); 对数据取整,并进行16bit量化 fid=fopen('Data_input.txt','w+'); 把原始数据存入文件Data_input.txt fprintf(fid,'%g\r\n',y2); fclose(fid); r7 g1 G+ ?, r- i; O& w+ I9 y
[Y, exp_out]= fft256_model(y2(1:256),N,0); 调用fft256_model
: K8 j d7 X$ E1 o把转换后的数据分别存入fft_real_output.txt和fft_imag_output.txt fid=fopen('fft_real_output.txt','w+'); fprintf(fid,'%g\r\n',real(Y)); fclose(fid);
$ _( b* f, g3 j( E# g7 y6 Q3 Yfid=fopen('fft_imag_output.txt','w+'); fprintf(fid,'%g\r\n',imag(Y)); fclose(fid); ; m |$ c5 g5 ~1 k4 e# e
Pyy = Y.* conj(Y) ; f = 1000*(0:128)/256; subplot(3,1,3); plot(f,Pyy(1:129)) title('Quantus中IPcore函数转换的结果') |