38 lines
1.1 KiB
Matlab
38 lines
1.1 KiB
Matlab
function [total_nf, total_gain, total_temp] = cal_nf(nf_set, gain_set, reftemp)
|
|
|
|
% Check inputs
|
|
narginchk(2,3);
|
|
|
|
% Validate
|
|
validateattributes(nf_set,{'double'}, {'nonnan','nonempty','real', ...
|
|
'vector','nonnegative'}, 'noisefigure', 'NF');
|
|
numNF = numel(nf_set);
|
|
validateattributes(gain_set,{'double'}, {'nonnan','nonempty','real', ...
|
|
'vector','numel',numNF}, 'noisefigure', 'G');
|
|
NFcol = db2pow(nf_set(:));
|
|
Gcol = db2pow(gain_set(:));
|
|
|
|
% Check for temperature input
|
|
if nargin < 3
|
|
reftemp = 290; % Standard noise temperature (Kelvin)
|
|
else
|
|
validateattributes(reftemp,{'double'}, {'finite','nonempty','real', ...
|
|
'nonnegative','scalar'}, 'noisefigure', 'REFTEMP');
|
|
end
|
|
|
|
% Calculate total gain
|
|
total_gain = sum(gain_set(:),1); % dB
|
|
|
|
% Calculate cascaded noise figure
|
|
if numel(NFcol) > 1
|
|
cnfLinear = NFcol(1) + sum((NFcol(2:end) - 1)./cumprod(Gcol(1:end-1),1),1); % Linear
|
|
total_nf = 10*log10(cnfLinear); % dB
|
|
else
|
|
cnfLinear = NFcol(1);
|
|
total_nf = nf(1);
|
|
end
|
|
|
|
% Calculate cascaded noise temperature
|
|
total_temp = reftemp*(cnfLinear); % Kelvin
|
|
|
|
end |