Add new functions

This commit is contained in:
Silas Oettinghaus
2025-02-17 21:31:12 +01:00
parent becaf3f6c9
commit d099efea03
21 changed files with 1502 additions and 272 deletions

View File

@@ -0,0 +1,54 @@
function showEQTimeSignal(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
options.color = [0.2157 0.4941 0.7216];
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
M = numel(unique(ref_symbols.signal));
lvlcol = cbrewer2('Set1',M);
col = cbrewer2('paired',2);
eq_decisions = PAMmapper(M,0).quantize(eq_signal);
rx_bits = PAMmapper(M,0).demap(eq_signal);
ref_bits = PAMmapper(M,0).demap(ref_symbols);
%%% Separate Classes
constellation = unique(ref_symbols.signal);
received_sd = NaN(numel(constellation),length(ref_symbols));
received_hd = 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.signal==constellation(lvl)) = eq_signal.signal(ref_symbols.signal==constellation(lvl));
received_hd(lvl,ref_symbols.signal==constellation(lvl)) = eq_decisions.signal(ref_symbols.signal==constellation(lvl));
end
[~,numerr,ber_sd,errpos] = calc_ber(rx_bits.signal,ref_bits.signal,"skip_front",100,"skip_end",150,"returnErrorLocation",1);
%%% EQ Time Series %210
eq_signal.plot("fignum",fig.Number,"displayname",'Equalized Signal','color',col(1,:),'clear',1);
hold on
try
yline(PAMmapper(M,0).get_demodulation_thresholds,'HandleVisibility','off','LineStyle','--');
for c = 1:M
scatter(errpos./eq_signal.fs,received_sd(c,errpos),1,'x','MarkerEdgeColor',lvlcol(c,:),'LineWidth',2,'DisplayName',sprintf('Tx Lvl: %d',c));
end
end
end