⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cp0101_bandwidth.m

📁 第一步是计算输人信号单边功率谱密度(ESD)。使用快 %速傅里叶(FFr)算法将信号从时域转换到频域。因为FFr算法的输出是离散谱
💻 M
字号:
%函数1.2.由三个步骤组成。第一步是计算输人信号单边功率谱密度(ESD)。使用快
%速傅里叶(FFr)算法将信号从时域转换到频域。因为FFr算法的输出是离散谱,而这
%里我们需要的是连续谱,因此需要引人不同的比例因子来实现从离散谱到连续谱的转换。
%在第二步中,我们利用迭代算法计算出相对于特定阂值的ESD的最高和最低频率,从而
%估算出被检测信号所占用的带宽。这种算法同时适用于基带信号和已调制信号。最后,
%在第三步中,我们给出了输出图形的原代码。


%FUNCTION 1.2 : "cp0101_bandwidth"
% Evaluates the bandwidth of the input 'signal'. with -
% sampling period 'dt'
%
% Bandwidth is evaluated according to the given 'threshold'
% (in dB)
% 'BW' is the bandwidth
% 'f_high' is the higher limit
% 'f_ low' is the lower limit 
% Programmed by Guerino Giancola

function [ss E, f high, f 10W, BW]=...
    cp0101_bandwidth(signal,dt,threshold)

%--------------------------------------------
%Step One - Evaluation of the single-sided ESD
%------------------------------- ---------------
fs = 1 / dt;             % sampling frequency
N = length(signal);      % number of samples (i.e.,size of the FFT)

T = N * dt;             % time window 
df = 1 / T;             % fundamental frequency

X =fft(signal);         % double-sided MATLAB amplitude spectrum
X = X/N;                % conversion from MATLAB spectrum to fourier spectrum

ds_E = abs(X).^2/(df^2); % double-sided ESD
ss_E = 2.*ds_E(l:floor(N/2)); % single-sided ESD


%--------------------------------------------
%Step Two - Evaluation of the frequency bandwidth
%--------------------------------------------.
[Epeak,index] = max(ss_E); % Epeak is the peak value of the ESD
f_peak = index * df;        % peak frequency `' ` '
Eth = Epeak*10^(threshold/10); % Eth `is the value of the ESD corresponding-=to the
given `"thresHold='`
.-.:;_ _._. ,
iterative algorithm for evaluating`high-and=low ' -
% frequencies
imax = index;
EOh = ss E(index) ;
while -(E Oh>Eth) & (imax<= (N/2) )
s. . imax.} _ , imax_ + 1;
i;} Eph = ss' g(-imax) ,-
.end %'while.EOh > Eth
. }' f' high -;; (iinax--1) *,: df; high--frequency; - ,
imin. = index; J =! . .
E01,= ss E(index);
while (E01>Eth)&(imin>1)&(index>1)' '
imin = imin - 1; . .. . . _
}Ep1'-:s = sLE (imiri)
ew .
end 7% while E01 > Eth
f,10
w =,(min(index,imin)-1) * df'; low-"frequency
% end of iterative a"lgbrthm'-` - '0
BW = f high - f _low; % signal frequency bandwidth,
fprintf('\nFrequency Bandwidth = %f [Hz]\nHigh Frequency =
%f [Hz]\nLow Frequency = %f ,.[Hz]\n',BW,f high,f-low);
Step Three - Graphical output
figure (2)
frequency=linspace(O,fs/2,length(ss_E));_ _
PF=plot(frequency,ss E);
set(PF;'LineWidth',[2]);
L1=line([f high f high],[min(ss E) max(ss E)]);
set(L1,'Color',[0 0 0],'LineStyle',!:')
Ll=line([f low f_low],[min(ss E) max(ss_E)]);
set(L1,'Color',[0 0 0],'LineStyle',':'7)-
Ll=1 in' (' [f_low f_'high] , [Eth Eth]) ;
set(L1,'LineWidth',[2],'Color',''red','LineStyle',':')
axis([0.8*f low 1.2*f high -0.1*Epeak 1.2*Epeak].);
AX = gca;
set(AX,!FontSize!,,12);
T=title('Frequency,domain');
set(T,'FontSize',14);
X=xlabel('Frequency [Hz]');
set(X,'FontSize',14);
Y=ylabel('Single-Sided ESD [V"2s/Hz]');
set(Y,'FontSize',14);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -