📄 bwcapacityread.m
字号:
function [sim_param, sim_state] = BwCapacityRead( sim_param )
% BwCapacityRead determines that capacity of FSK under bandwidth
% constraints, by returning min Eb/No (dB) as a function of h.
%
% The calling syntax is:
% sim_state = OutageRead( sim_param, sim_state )
%
% Required inputs/outputs:
% sim_param = A structure containing simulation parameters.
%
% Required output
% sim_state = A structure containing the simulation state.
%
% Note: See readme.txt for a description of the structure formats.
%
% Copyright (C) 2006, Matthew C. Valenti
%
% Last updated on May 7, 2006
%
% Function BWCapacityRead is part of the Iterative Solutions Coded Modulation
% Library (ISCML).
%
% The Iterative Solutions Coded Modulation Library is free software;
% you can redistribute it and/or modify it under the terms of
% the GNU Lesser General Public License as published by the
% Free Software Foundation; either version 2.1 of the License,
% or (at your option) any later version.
%
% This library is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
% Lesser General Public License for more details.
%
% You should have received a copy of the GNU Lesser General Public
% License along with this library; if not, write to the Free Software
% Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
epsilon = 1e-4; % a small number
% initialize the state
number_new_SNR_points = [];
sim_state.trials = [];
sim_state.capacity_sum = [];
sim_state.capacity_avg = [];
sim_state.frame_errors = [];
sim_state.symbol_errors = [];
sim_state.bit_errors = [];
sim_state.FER = [];
sim_state.SER = [];
sim_state.BER = [];
sim_state.throughput = [];
sim_state.minEbNodB = zeros(1,length( sim_param.scenarios ));
sim_state.minEsNodB = zeros(1,length( sim_param.scenarios ));
sim_state.bestrate = zeros(1,length( sim_param.scenarios));
sim_state.h = length( sim_param.scenarios );
% read in the simulation results
[read_param, read_state] = ReadScenario( sim_param.input_filename, sim_param.scenarios );
number_records = length( sim_param.scenarios );
% read in the database
% should contain a BwMatrix matrix with three columns
% First column is M, second is h, and third is uncoded BW
load( sim_param.bwdatabase );
% go through each record
for record=1:number_records
% store the h value
sim_state.h(record) = read_param(record).h;
% for this h and M, determine the bandwidth from the database
M_values = find( BwMatrix(:,1) == read_param(record).mod_order );
h_values = find( abs(BwMatrix(:,2) - read_param(record).h) < epsilon);
Matching_row = min( intersect( M_values, h_values ) );
bandwidth = BwMatrix( Matching_row, 3 );
% determine the minimum allowable code rate
min_rate = bandwidth/log2(read_param(record).mod_order)/sim_param.bwconstraint;
sim_state.min_rate(record) = min_rate;
% determine which Es/No point corresponds to the min_rate
r = read_state(record).capacity_avg;
rindex = find( r>epsilon & r< 1-epsilon);
best_EsNodB = interp1( r(rindex), read_param(record).SNR(rindex), min_rate );
% convert to Eb/No (dB)
best_EsNo = 10.^(best_EsNodB/10);
best_EbNo = best_EsNo/(min_rate*log2( read_param(record).mod_order ));
best_EbNodB = 10*log10( best_EbNo );
% see if a higher rate is actually better
EsNo = 10.^( read_param(record).SNR/10 );
rindex = find( r >= min_rate & r < 1-epsilon);
rvalues = r( rindex );
EbNo = (EsNo(rindex)./rvalues)/log2( read_param(record).mod_order );
EbNodB = 10*log10( EbNo );
if ( min( EbNodB ) < best_EbNodB )
[y,i] = min(EbNodB);
best_EbNodB = y;
min_rate = rvalues(i);
EsNodB_rindex = read_param(record).SNR(rindex);
best_EsNodB = EsNodB_rindex(i);
fprintf( 'best rate is %f\n', min_rate );
end
sim_state.minEbNodB(record) = best_EbNodB;
sim_state.minEsNodB(record) = best_EsNodB;
sim_state.bestrate(record) = min_rate;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -