changes from zurich; my mac
This commit is contained in:
@@ -3,13 +3,15 @@ classdef Pulseformer
|
||||
% Detailed explanation goes here
|
||||
|
||||
properties(Access=public)
|
||||
fdac
|
||||
|
||||
end
|
||||
properties(Access=private)
|
||||
properties(Access=public)
|
||||
fdac
|
||||
fsym
|
||||
pulse
|
||||
pulselength
|
||||
rrcalpha
|
||||
alpha
|
||||
matched
|
||||
end
|
||||
|
||||
methods (Access=public)
|
||||
@@ -20,9 +22,10 @@ classdef Pulseformer
|
||||
arguments
|
||||
options.fdac double
|
||||
options.fsym double
|
||||
options.pulse pulseform = pulseform.rrc
|
||||
options.pulse pulseform = pulseform.rc
|
||||
options.pulselength double {mustBeInteger} = 32
|
||||
options.rrcalpha double = 0.05
|
||||
options.alpha double = 0.05
|
||||
options.matched = 0;
|
||||
end
|
||||
|
||||
%
|
||||
@@ -86,49 +89,72 @@ classdef Pulseformer
|
||||
sps= up;
|
||||
end
|
||||
|
||||
if obj.pulse == pulseform.rrc
|
||||
%Bau das Filter (hier rrc)
|
||||
racos_len = obj.pulselength*2;
|
||||
alpha = obj.rrcalpha;
|
||||
h = rcosdesign(alpha,racos_len,sps,"normal");
|
||||
if obj.pulse == pulseform.rc
|
||||
filtertype = 'normal';
|
||||
elseif pulseform.rrc
|
||||
filtertype = 'sqrt';
|
||||
end
|
||||
|
||||
%Bau das Filter (hier rc)
|
||||
racos_len = obj.pulselength*2;
|
||||
h = rcosdesign(obj.alpha,racos_len,sps,filtertype);
|
||||
h = h./ max(h);
|
||||
|
||||
if obj.matched
|
||||
h = 1./h;
|
||||
end
|
||||
|
||||
manual_cyclic_convolution = 1;
|
||||
upfirdn_convolution = 0;
|
||||
|
||||
if manual_cyclic_convolution
|
||||
|
||||
% Apply filter the long way (from move_it)
|
||||
data_in = data_in';
|
||||
blen = length(data_in)*sps;
|
||||
|
||||
% oversample symbol sequence
|
||||
symbolov=zeros(size(data_in,1),blen);
|
||||
symbolov(:,1:sps:blen-sps+1)=data_in;
|
||||
H=fft(h,blen);
|
||||
|
||||
% Convolution of Bit sequence with impulse response
|
||||
data_out=ifft( fft(symbolov.') .* repmat( H,size(data_in,1),1 ).' ).';
|
||||
data_out = circshift(data_out,[0 -(obj.pulselength*sps)]);
|
||||
|
||||
if rem(obj.fdac,obj.fsym)
|
||||
data_out = data_out(1:dn:end);
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if upfirdn_convolution
|
||||
|
||||
%Apply Filter using Matlab build in fctn.
|
||||
h = rcosdesign(obj.alpha,racos_len,sps,"normal");
|
||||
h = h./ max(h);
|
||||
data_out_ = upfirdn(data_in,h,up,dn);
|
||||
|
||||
%cut signal, which is longer due to fir filter
|
||||
st = round(up/dn*racos_len/2)+1; %we need to cut y_out
|
||||
en = round(st + (length(data_in)*up/dn));
|
||||
data_out_ = data_out_(st:en);
|
||||
|
||||
end
|
||||
|
||||
% Apply filter the long way (from move_it)
|
||||
% block length in samples
|
||||
|
||||
data_in = data_in';
|
||||
blen = length(data_in)*sps;
|
||||
|
||||
% oversample symbol sequence
|
||||
|
||||
symbolov=zeros(size(data_in,1),blen);
|
||||
symbolov(:,1:sps:blen-sps+1)=data_in;
|
||||
|
||||
H=fft(h,blen);
|
||||
|
||||
% Convolution of Bit sequence with impulse response
|
||||
|
||||
% cyclic convolution
|
||||
data_out=ifft( fft(symbolov.') .* repmat( H,size(data_in,1),1 ).' ).';
|
||||
|
||||
data_out = circshift(data_out,[0 -(obj.pulselength*sps)]);
|
||||
|
||||
if rem(obj.fdac,obj.fsym)
|
||||
data_out = data_out(1:dn:end); %!
|
||||
if upfirdn_convolution && manual_cyclic_convolution
|
||||
figure()
|
||||
subplot(2,1,1)
|
||||
title("Convolution vs. Upfirdn and Cut")
|
||||
hold on
|
||||
plot(data_out_(1:200),'DisplayName','Matlab upfirdn');
|
||||
plot(data_out(1:200),'DisplayName','By Hand cyclic convolution')
|
||||
subplot(2,1,2)
|
||||
hold on
|
||||
plot(data_out(1:2000),'DisplayName','OUT');
|
||||
plot(data_in(1:2000),'DisplayName','IN');
|
||||
end
|
||||
|
||||
|
||||
% %Apply Filter using Matlab build in fctn.
|
||||
% h = rcosdesign(alpha,racos_len,sps);
|
||||
% h = h./ max(h);
|
||||
%data_out_ = upfirdn(data_in,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(data_in)*up/dn) -1);
|
||||
% data_out = data_out(st:en);
|
||||
|
||||
%scaling?! see pulsef module line 696
|
||||
% scale = max(max([abs(real(data_out)) abs(imag(data_out))])); %find max value from real and imag part
|
||||
% data_out = data_out./scale;
|
||||
|
||||
Reference in New Issue
Block a user