📄 part1b.m
字号:
clc;
close all;
echo off;
fd=100;
M=8;
N=4*M+2;
Ts=1e-4;
Ns=100;
maxlags=1000;
% u=[];
uc=zeros(M+1,10001);
us=zeros(M+1,10001);
u=zeros(M+1,10001);
norm_temp=zeros(M+1,maxlags);
corr_sum=zeros(M+1,maxlags);
for i=1:10
t=i:Ts:i+1;
suma=0;
sumb=0;
for n=1:M+1
if n<=M
a=2*cos(pi*n/M);
b=2*sin(pi*n/M);
w=2*pi*fd*cos(2*pi*n/N);
else
a=sqrt(2)*cos(pi/4);
b=sqrt(2)*sin(pi/4);
w=2*pi*fd;
end
suma=suma+(a*cos(w*t));
sumb=sumb+(b*sin(w*t));
end
uc(i,:)=sqrt(4/N)*suma;
us(i,:)=sqrt(4/N)*sumb;
u(i,:)=uc(i,:)+(j*us(i,:));
%plot(i:Ts:i+1,abs(u));
temp=xcorr(u(i,:),maxlags);
norm_temp(i,:)=[temp(1:maxlags)]/norm(real(temp),inf);
corr_sum(i,:)=flipdim(norm_temp(i,:),2);
end
plot([1:maxlags]*fd*Ts,corr_sum);
title('Autocorrelation of U(t) at 10 different time instants');
xlabel('Time lag s');
ylabel('Autocorrelation');
figure;
for i=1:10
[m,n]=hist(abs(u(i,:)),100);
su=sum(m);
m=m/su/(n(2)-n(1));
t1=i*ones(1,length(n));
plot3(t1,n,m);
grid on;
hold on;
end
title('PDF of U(t)');
ylabel('Bins');
zlabel('Normalised Probability ');
xlabel('Time');
% figure;
% for i=1:10
% t=i:Ts:i+1;
%
% plot(t,u(i,:));
% grid on;
% hold on;
% end
% [m,n]=hist(u,50);
% su=sum(m);
% m=m/su;
% figure;
% % subplot(3,1,1),
% plot(n,m);
% title('PDF of Uc(t)');
% xlabel('Bins');
% ylabel('Normalised Probability');
%
%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -