function [rate, margin]=calcResultSCM_cRate(f,lc,alpha,SNRmax,reqSNR,SNR,fc,fs,useFixBitrate,fixConstellation) %% =========================================================================== %calcResultSCM_cRate - Local function used to calculates the rate % for a SCM system % % Parameters: f Frequency axis % lc The linecode % ... % % Returns: rate Resulting bitrate (in Mbit) % margin Margin (in dB) % %% =========================================================================== %% =========================================================================== % Copyright (C): % 2005-2009 by Forschungszentrum Telekommunikation Wien, Austria; % All rights reserved. % Project : FTW's xDSLsimu % Author(s) : Tomas Nordstrom (Tomas.Nordstrom@FTW.at) % % CVS: $Id: calcResultSCM.m 572 2005-01-10 16:24:35Z tono $ %% =========================================================================== % Change History % 2005-05-13 (ToNo) Split out from calcResultSCM to avoid % local functions %% =========================================================================== if nargin<8, error('Not enough input arguments.'); end if nargin<9, useFixBitrate = 0; fixConstellation = 0; end FILT=sqrcPSD(f,alpha,fs,fc); Rx=SNR.*FILT; Rx(find(Rx>=10.^(SNRmax/10)))=10.^(SNRmax/10).*ones(size(find(Rx>=10.^(SNRmax/10)))); nofs=length(fs); b = zeros(1,nofs); M = zeros(1,nofs); for a=1:nofs, T=1./fs(a); f_min=-(1/(2*T).*(1+alpha))+fc(a); f_max=(1/(2*T).*(1+alpha))+fc(a); f_ind=find((f>=f_min)&(f<=f_max)); totSNR=10*log10(trapz(f(f_ind),Rx(f_ind))./(f_max-f_min)); ind=find((totSNR-reqSNR)>=0); if ~isempty(ind), % Check if the constellation is fixed? if useFixBitrate, newIndex=find(fixConstellation(a) >= lc.param.constellation); % Change index vector if the fixed one point out smaller constellations if max(newIndex) < max(ind), ind = newIndex; end; end; b(a)=lc.param.constellation(max(ind)); M(a)=totSNR-reqSNR(max(ind)); end; end; rate=sum(b.*fs); margin=mean(M);