function rate=calcRate(b,f,f_start,f_stop); %% =========================================================================== %calcRate - Calculates the total rate from f_start to f_stop % % Parameter: b bitloading vector % Parameter: f frequency axis % Parameter: f_start start of used frequency band % Parameter: f_stop stop of used frequency ban % Returns: rate the bitrate in the used band % % % Example(s): % rate=calcRate(b,f,30e3,1.108e6); % % Algorithmic details: % The calculation of the rate is basically a approximative % calculation of an integral, with b and f as the y- and x-axis. The % algorithm approxiamtes the integral by taking the average value % between two points multiplied with the frequency difference of the % two points. % % Reference: % FSAN xDSL simulation tool manual %% =========================================================================== %% =========================================================================== % Copyright (C) 1999 by Telia Research AB, Lulea, Sweden; All rights reserved. % Project : FSAN duplex model % Author(s) : Tomas Nordstrom (Tomas.Nordstrom@FTW.at) % : Daniel Bengtsson (Daniel.J.Bengtsson@Telia.se) % % CVS: $Id: calcRate.m %% =========================================================================== % Change History % 1999-01-07 (DaB) Created %% =========================================================================== index=find((f>=f_start)&(f<=f_stop)); f_used=f(index); delta_f=diff(f_used); b_used=b(index); tmp=b_used(2:length(b_used)); tmp2=b_used(1:length(b_used)-1); rate=(tmp2+tmp)./2*delta_f';