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

📄 bandwidth.m

📁 超宽带无线通信的带宽仿真程序
💻 M
字号:
%
% 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_low,BW] = ...
   cp0101_bandwidth(signal,dt,threshold)

% -----------------------------------------------------------------
% Step One - Evaluation of the single-sided Energy Spectral Density
% -----------------------------------------------------------------

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 spec-trum
ds_E = abs(X).^2/(df^2);      % DOUBLE-SIDED ENERGY SPECTRAL DENSITY
ss_E = 2.*ds_E(1:floor(N/2)); % SINGLE-SIDED ENERGY SPECTRAL DENSITY

% ------------------------------------------------
% 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;
E0h = ss_E(index);

while (E0h>Eth)&(imax<=(N/2))

    imax = imax + 1;
    E0h = ss_E(imax);

end % while E0h > Eth

f_high = (imax-1) * df;             % High Frequency

imin = index;
E0l = ss_E(index);

while (E0l>Eth)&(imin>1)&(index>1)

    imin = imin - 1;
    E0l = ss_E(imin);

end % while E0l > Eth

f_low = (min(index,imin)-1) * df;   % Low Frequency

% end of iterative algorithm

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(0,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',':')
L1=line([f_low f_low],[min(ss_E) max(ss_E)]);
set(L1,'Color',[0 0 0],'LineStyle',':')
L1=line([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 + -