赞
踩
有IQ两路,16位量化,采样率80MHz
- %读取数据
- filename = 'iladata.csv'; %文件地址
- data = csvread(filename,2,0); %读取csv文件
- function [fbj] = figurePlot(realdata, fs)
- % figurePlot画图函数
- %realdata:数据
- %fs:采样率
- [~,harmpow,harmfreq] = thd(realdata(:,2),fs,5); %调用thd分析函数
- fbj = figure;
- thd(realdata(:,1),fs,5);
- hold on;
- %标注谐波
- for i = 1:5
- text(harmfreq(i)/1e6,harmpow(i) + 10,num2str(harmfreq(i)/1e6),'Color','red');
- end
- ylabel('dB Fs'); %标注y轴
- ylim auto %标注x轴
- title('');
- end
- %%
- %参数测量
- n = length(realdata);
- w = kaiser(n, 38);
- rbw = enbw(w, fs);
- [Pxx, F] = periodogram(realdata(:,1), w, n, fs, 'psd');
- Pxx = 10*log10(Pxx*rbw);
-
- [max_value, max_index] = max(Pxx); %求最大功率点与最大功率
- [min_value, ~] = min(Pxx); %求最小功率点与最小功率
- s_Fund = max_value; %Fund :dB Fs
- s_nsd = min_value - max_value; %NSD :dBc
- [r, harmPow, harmFreq] = thd(realdata(:,1),fs,5);
- s_hd2 = harmPow(2) - harmPow(1); %HD2 :dBc
- s_hd3 = harmPow(3) - harmPow(1); %HD3 :dBc
- s_hd4 = harmPow(4) - harmPow(1); %HD4 :dBc
- s_hd5 = harmPow(5) - harmPow(1); %HD5 :dBc
-
- sumharmPow = 0;
- for i =2: 5
- sumharmPow = sumharmPow + 10^(0.1*harmPow(i));
- end
- s_thd = 10*log10((10^(0.1*harmPow(1)))/sumharmPow);%THD :dBc, THD = 10*log(S/D),S为信号功率,D为杂波功率
-
- temp = Pxx(max_index-5:max_index + 5);
- Pxx(max_index-5:max_index + 5) = min_value;
- [next_max_value, next_max_index] = max(Pxx);
- Pxx(max_index-5:max_index + 5) = temp;
- s_next_supr = next_max_value - max_value; %Next Supr:dBc
- s_sfdr = - s_next_supr; %SFDR: dBc
-
- s_sinad = sinad(realdata(:,1),fs); %SINAD: dBc
- s_enob = (s_sinad - s_Fund - 1.76)/6.02; %ENOB: Bits
- s_snr = snr(realdata(:,1), fs); %SNR: dBc
-
-
- %控制台输出
- disp(['SNR:' num2str(s_snr) ' dBc']);
- disp(['SFDR:' num2str(s_sfdr) ' dBc']);
- disp(['THD:' num2str(s_thd) ' dBc']);
- disp(['SINAD:' num2str(s_sinad) ' dBc']);
- disp(['ENOB:' num2str(s_enob) ' Bits']);
- disp(['Fund.:' num2str(s_Fund) ' dBc']);
- disp(['Next supr:' num2str(s_next_supr) ' dBc']);
- disp(['HD2:' num2str(s_hd2) ' dBc']);
- disp(['HD3:' num2str(s_hd3) ' dBc']);
- disp(['HD4:' num2str(s_hd4) ' dBc']);
- disp(['HD5:' num2str(s_hd5) ' dBc']);
- disp(['NSD:' num2str(s_nsd) ' dBc']);
- function outlo = filter_my(data,fs,f_max,BW)
- %滤波函数
- %data:数据
- %fs:采样率
- %f_max:中心频率点
- %BW:带宽
-
-
- Fs = fs/1e6;
- N = 128; %滤波器阶数
- Fc1 = f_max - BW/2; %%自适应通带
- Fc2 = f_max + BW/2;
- flag = 'noscale';
-
- win = hamming(N+1); %窗函数
-
- blo = fir1(N, [Fc1 Fc2]/(Fs/2), 'bandpass', win, flag); %滤波器
-
- outlo = filter(blo,1,data);
-
-
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。