changes from friday

This commit is contained in:
Silas Oettinghaus
2023-05-21 15:31:39 +02:00
parent 8d098a6c80
commit f5747bb863
9 changed files with 311 additions and 187 deletions

View File

@@ -0,0 +1,34 @@
function yout = applyPulseShaping(xin,fsym,fdac)
if ~rem(fdac,fsym)
%ist ein Vielfaches
sps = fdac / fsym;
up = sps;
dn = 1;
else
%ist kein Vielfaches
up = fdac / gcd(fdac, fsym);
dn = fsym / gcd(fdac, fsym);
sps= up;
end
%Bau das Filter (hier rrc)
racos_len = 2048;
alpha = 0.1;
h = rcosdesign(alpha,racos_len,sps);
%Apply Filter using Matlab build in fctn.
yout = upfirdn(xin,h,up,dn);
%cut signal, which is longer due to fir filter
st = round(up/dn*racos_len/2); %we need to cut y_out
en = round(st + (length(xin)*up/dn) -1);
yout = yout(st:en);
%Check output integrity
if round(up/dn * length(xin)) ~= length(yout)
warning('Check signal length after pulse shaping');
end
end

28
Functions/calc_ber.m Normal file
View File

@@ -0,0 +1,28 @@
function [bits,errors,BER] = calc_ber(data_in,data_ref,skip)
data_ref=logical(data_ref);
data_in = logical(data_in);
bits = 0;
errors=0;
data_ref_overlap=zeros(size(data_ref,1),skip+(length(data_ref)-size(data_in,2)));
data_ref_pointer=0;
% Determine BER
bits = bits+size(data_in,2)-skip;
try
errors = sum( data_in(:,skip+1:end,:) ~= data_ref(:,skip+1:end,:),2 );
catch
%warning('BER calculation not optimal: Arrays have incompatible sizes for this operation.')
errors = NaN;
end
try
errors = sum( data_in(:,skip+1:end,:) ~= data_ref(:,skip+1:end-1,:),2 );
end
try
errors = sum( data_in(:,skip+1:end,:) ~= data_ref(:,skip+1:end-2,:),2 );
end
BER = sum(errors)/sum(bits);
end