51 lines
1.5 KiB
Matlab
51 lines
1.5 KiB
Matlab
function showLevelHistogram(eq_signal,ref_symbols,options)
|
|
arguments
|
|
eq_signal
|
|
ref_symbols
|
|
options.fignum (1,1) double = NaN % Default to NaN if not provided
|
|
options.displayname (1,:) char = '' % Default to an empty string if not provided
|
|
end
|
|
|
|
if isa(eq_signal,'Signal')
|
|
eq_signal = eq_signal.signal;
|
|
end
|
|
if isa(ref_symbols,'Signal')
|
|
ref_symbols = ref_symbols.signal;
|
|
end
|
|
|
|
% Determine the figure number to use or create a new figure
|
|
if isnan(options.fignum)
|
|
fig = figure; % Create a new figure and get its handle
|
|
else
|
|
fig = figure(options.fignum); % Use the specified figure number
|
|
end
|
|
|
|
%%% Separate Classes
|
|
constellation = unique(ref_symbols);
|
|
received_sd = NaN(numel(constellation),length(ref_symbols));
|
|
lvlcol = cbrewer2('Set1',numel(constellation));
|
|
for lvl = 1:numel(constellation)
|
|
%Separate the equalized signal into the
|
|
%respective levels based on the actually
|
|
%transmitted level!
|
|
received_sd(lvl,ref_symbols==constellation(lvl)) = eq_signal(ref_symbols==constellation(lvl));
|
|
end
|
|
|
|
|
|
|
|
%%% FFE histogram
|
|
clf
|
|
for lvl = 1:numel(constellation)
|
|
intermediate = received_sd(lvl,:);
|
|
cnt(lvl) = round(numel(intermediate(~isnan(intermediate)))./length(eq_signal),3).*100;
|
|
hold on
|
|
histogram(received_sd(lvl,:),1000,"EdgeAlpha",0,'DisplayName',['Lvl ',num2str(lvl),' | ',num2str(cnt(lvl)),' %'],'FaceColor',lvlcol(lvl,:),'Normalization','pdf');
|
|
end
|
|
legend
|
|
grid on
|
|
|
|
|
|
|
|
end
|
|
|