📄 basetimcost.m
字号:
% basetimcost.m: draw error surfaces for baseband signal cost functions
% in terms of chosen pulse shape
% crj jr, revised 4/22/03
clear all
m=20; % evaluate at m+1 different points
unp=hamming(m);
cp=conv(unp,unp); % receiver matched filter makes combo pulse
ps=sqrt(m)*cp/sqrt(sum(cp.^2)); %normalized combo pulse shape
cost1=zeros(1,m+1); cost2=zeros(1,m+1); cost3=zeros(1,m+1);
cost4=zeros(1,m+1); cost5=zeros(1,m+1);
n=1000; x=zeros(1,n); % calculate cost via a "monte carlo" method
for i=1:m+1 % for each offset
% create +/-1 sequence
s1=sign(rand([1,n/m])-0.5);
s2=sign(rand([1,n/m])-0.5);
% zero pad T-spaced symbol sequence to create upsampled T/m-spaced
% sequence of scaled T-spaced pulses (with T = 1 time unit)
mup1=zeros(1,n); mup1(1:m:end)=s1;
mup2=zeros(1,n); mup2(1:m:end)=s2;
m1=filter(ps,1,mup1); % convolve pulse shape with data
m2=filter(ps,1,mup2); % convolve pulse shape with data
%sampled baseband data with timing offset iT/m
sm1=m1((length(ps)-1)/2+i:m:end);
sm2=m2((length(ps)-1)/2+i:m:end);
cost1(i)=sum(sqrt(sm1.^2+sm2.^2))/length(sm1); % cost (abs value sum)
cost2(i)=sum(sm1.^2+sm2.^2)/length(sm1); % cost (square)
cost3(i)=sum((sm1.^2+sm2.^2).^2)/length(sm1); % cost (4th power sum)
cost4(i)=sum(abs(sm1)+abs(sm2))/length(sm1); % cost (sum of abs)
cost5(i)=sum(sm1.^4+sm2.^4)/length(sm1); % cost (sum of 4th power)
end
offset=(0:m)/m;
figure(1)
plot(offset,cost1,'--'), hold on % cost (absolute value)
plot(offset,cost2,':'), % cost (square)
plot(offset,cost3,'-'), % cost (4th power)
plot(offset,cost4,'.'),
plot(offset,cost5,'-.'),
hold off, zoom on
xlabel('timing offset \tau')
ylabel('value of cost functions')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -