现对平稳随机过程(其中
为在
上均匀分布的随机变量
,
和
为常数)的样本经过线性系统进行仿真。
线性系统如下:
function [ y ] = Linearsystem(x1,a,b)
%Linearsystem 线性时不变系统
%x-随机过程,a,b-线性系统参数,y-输出
y=a*x1+b;
end
此处令,该随机过程的样本通过线性系统,此处的线性系统冲击相应为
。
clear all
clc
%----------------------------------------------平稳随机过程
T=0.05; %采样周期
fs=1/T; %采样频率
t1=-200:T:200;
N=length(t1);
k=0:N-1;
tau=5; %时移
t2=t1+tau;
fi=2*pi*rand(1,10);
for i=1:5
X0(i,:)=2*cos(t1+fi(i)); %频率w=1(rad/s)的随机过程
X1(i,:)=2*cos(t2+fi(i));
end
% figure
% subplot(2,1,1),plot(t1,X0)
% title('X(t)');xlabel('t');ylabel('X(t)');
% subplot(2,1,2),plot(t2,X1);
% title('X(t+\tau)');xlabel('t+\tau');ylabel('X(t)');
Ex=mean(mean(X0)); %均值
Rx=mean(mean(X0.*X1)); %自相关函数
Exx=mean(mean(X0.^2)); %均方值
% figure
% subplot(1,3,1);plot(t1,Ex,'-*');
% title('均值');xlabel('t');ylabel('m_X(t)]');
% subplot(1,3,2);plot(t1,Rx,'-^');
% title('自相关函数');xlabel('t');ylabel('R_X(t_1,t_2)');
% subplot(1,3,3);plot(t1,Exx,'-o');
%------------------------平稳随机过程的样本函数经过线性系统后的输出
x0=X0(1,:); %样本函数
figure
subplot(2,1,1),plot(t1,x0),axis([-220,220,-3,3])
title('样本函数(时域输入)'),xlabel('t'),ylabel('x(t)')
FtX=fft(x0);
w=2*pi*(k/N*fs-fs/2); %频域横坐标
subplot(2,1,2),plot(w,abs(fftshift(FtX))),xlim([-5,5])
title('样本函数(频域输入)'),xlabel('\omega (rad/s)'),ylabel('振幅')
h=Linearsystem(t1,2,30); %系统函数
h=repmat(h,5,1);
figure
subplot(2,1,1),plot(t1,h(1,:))
title('线性系统(时域)'),xlabel('t'),ylabel('h(t)')
H=fft(h(1,:));
subplot(2,1,2),plot(w,abs(fftshift(H))),xlim([-5,5])
title('线性系统(频域)'),xlabel('\omega (rad/s)'),ylabel('振幅')
y=conv(x0,h(1,:));
tt=-400:0.05:400; %卷积后时域横轴坐标
figure
subplot(2,1,1),plot(tt,y),xlim([-440,440])
title('输出(时域)'),xlabel('t'),ylabel('y(t)')
Y=fft(y);
ww=2*pi*((0:length(Y)-1)*fs/length(Y)-fs/2); %卷积后频域横轴坐标
subplot(2,1,2),plot(ww,abs(fftshift(Y))),xlim([-5,5])
title('输出(频域)'),xlabel('\omega (rad/s)'),ylabel('振幅')
结果如图3所示
![](https://i-blog.csdnimg.cn/blog_migrate/7b96be5a4315cb1499fd084c45fa42d2.jpeg)
![](https://i-blog.csdnimg.cn/blog_migrate/a7cd9e01d92dc7d2bcdbc1b61b44b5c8.jpeg)
![](https://i-blog.csdnimg.cn/blog_migrate/d43dafd0e5d4bcde9e9d1950e54d4a75.jpeg)
可以看到,一个频域频率的余弦信号通过线性系统后,在时域上,输出信号表现为信号外部有系统函数相同的包络,该包络是与系统函数性质相同,都是线性的;在频域上信号的能量增强。可以看到经过线性系统后多了
的成分,刺成份与相位无关,(以余弦信号为例),原因如下:
而之所以,输出信号的两段包络不同,是因为,余弦信号(样本函数)在时域有一个相移,因此会有这样的结果。而实际上,若正余弦信号的相移
即无相移的情况下,通过线性系统后的结果应如图4、图5所示。信号相移对通过线性系统后的信号的影响为,两段输出信号绕各自旋转中心旋转。
![](https://i-blog.csdnimg.cn/blog_migrate/5d488da52b549639d473cc674f6fb2b3.jpeg)
![](https://i-blog.csdnimg.cn/blog_migrate/56bddc5e0784d7cd29fe546b29864af3.jpeg)
下面通过MATLAB仿真进行证明。
clear all
clc
T=0.05; %采样周期
fs=1/T; %采样频率
t=-200:T:200;
fi=pi*(0:0.1:2); %相位
h=2*t+5;
%figure,plot(t,h),title('线性系统')
for i=1:length(fi)
x(i,:)=cos(t+fi(i));
y(i,:)=conv(x(i,:),h);
end
%figure,plot(t,x(1,:));title('余弦信号')
%------------------正弦信号相位不同,经过线性系统后输出的包络不同
tt=-400:T:400; %卷积后时域横轴坐标
% for i=1:length(fi)
% figure
% plot(tt,y(i,:)),xlim([-440,440])
% end
%--------------------------------正余弦信号经过线性系统后的包络
x1=sin(t);
y1=conv(x1,h);
x2=cos(t);
y2=conv(x2,h);
figure,plot(tt,y1),xlim([-440,440])
title('正弦信号经过线性系统'),xlabel('t'),ylabel('y(t)')
figure,plot(tt,y2),xlim([-440,440])
title('余弦信号经过线性系统'),xlabel('t'),ylabel('y(t)')
由于图像太多,此处不再一一展示。