DB and 400G and minor changes

This commit is contained in:
Silas Oettinghaus
2024-10-07 08:22:28 +02:00
parent 179a7f9682
commit da3be973e2
20 changed files with 578 additions and 142 deletions

View File

@@ -192,6 +192,19 @@ classdef Signal
end
%% Add signals from one signal to another, the first object will sustain
function Difference = minus(X,y)
if isa(y,'Signal')
Difference = X;
Difference.signal = X.signal - y.signal;
elseif isnumeric(y)
Difference = X;
Difference.signal = X.signal - y;
end
end
function Product = times(X,y)
if isa(y,'Signal')
@@ -271,14 +284,22 @@ classdef Signal
N = 2^(nextpow2(length(obj.signal))-8);
[p_lin,w] = pwelch(obj.signal,hanning(N),N/2,N,obj.fs,"centered","power","mean");
p_dbm = 10*log10(p_lin)+30; %dB to dBm in case of "power"
normalize = 1;
if normalize
p_lin = p_lin./ max(p_lin);
p_dbm = 10*log10(p_lin); %dB to dBm in case of "power"
ylab = "normalized to 0 dB";
else
p_dbm = 10*log10(p_lin)+30; %dB to dBm in case of "power"
ylab = "Power (dBm)";
end
figure(options.fignum); % If figure does not exist, create new figure
hold on
plot(w.*1e-9,p_dbm,'DisplayName',options.displayname,'LineWidth',1);
xlabel("Frequency in GHz");
%ylabel("Power/frequency (dB/Hz)");
ylabel("Power (dBm)");
ylabel(ylab);
xlim([-obj.fs/2 obj.fs/2].*1e-9)
edgetick = 2^(nextpow2(obj.fs*1e-9));
% xticks([-edgetick:16:edgetick]);
@@ -362,7 +383,7 @@ classdef Signal
end
%%
%% Normalize
function obj = normalize(obj,options)
arguments
@@ -381,7 +402,7 @@ classdef Signal
end
%%
%% Delay
function [obj] = delay(obj,delay,options)
arguments
@@ -402,7 +423,7 @@ classdef Signal
end
%%
%% Synchronize with reference
function [obj,D,cuts] = tsynch(obj,options)
% time sync and cut
arguments
@@ -446,6 +467,10 @@ classdef Signal
end
function obj = filter(obj,a,b)
obj.signal = filter(a,b,obj.signal);
end
function er = extinctionratio(obj,fsym,M)
histpoints = 1024; %% verticale resolution
histpoints = floor(histpoints/2)*2+1; %% to have the eye digram centered around one point make the vertical resolution uneven