48 lines
1.5 KiB
Matlab
48 lines
1.5 KiB
Matlab
function [ach_inf_rate] = calc_air(test_signal,reference_signal,options)
|
||
% Calculation of AIR acc. to J. Kozesnik, „Numerically Computing Achievable Rates of Memoryless Channels“, Francisco Javier Garcıa-Gomez, doi: 10.1007/978-94-009-9857-5.
|
||
% Implementation is not accessible, I mailed TUM to get the code...
|
||
|
||
arguments(Input)
|
||
test_signal;
|
||
reference_signal;
|
||
options.skip_front = 0;
|
||
options.skip_end = 0;
|
||
options.returnErrorLocation = 0;
|
||
end
|
||
|
||
options.skip_end = abs(options.skip_end);
|
||
options.skip_front = abs(options.skip_front);
|
||
|
||
assert((options.skip_end+options.skip_front)<length(test_signal),"You can not skip more bits than overall length of data! Set skip_front or skip_end to lower value or check data_in");
|
||
|
||
if isa(reference_signal,'Signal')
|
||
reference_signal = reference_signal.signal;
|
||
end
|
||
|
||
if isa(test_signal,'Signal')
|
||
test_signal = test_signal.signal;
|
||
end
|
||
|
||
% TRIM
|
||
[test_signal,reference_signal]=trimseq(test_signal,reference_signal,options.skip_front,options.skip_end);
|
||
|
||
% CALC EVM
|
||
%%% new implementation of AIR
|
||
constellation = unique(reference_signal);
|
||
reference_idx = arrayfun(@(x) find(constellation == x, 1), reference_signal);
|
||
ach_inf_rate = air_garcia_implementation(constellation',test_signal',reference_idx');
|
||
|
||
|
||
function [data_,reference_]=trimseq(data,reference,skipstart,skip_end)
|
||
|
||
data_ = data(skipstart+1:end-skip_end,:);
|
||
|
||
delta_bits = length(reference) - length(data);
|
||
|
||
skip_end = delta_bits + skip_end;
|
||
|
||
reference_ = reference(skipstart+1:end-skip_end,:);
|
||
|
||
end
|
||
|
||
end |