5-4.m
来自「经典数字信号处理滤波器的源代码 重点是利用巴特沃斯模拟滤波器转而设计其它数字滤」· M 代码 · 共 32 行
M
32 行
%例程5-4 计算随机信号的自协方差函数与互协方差函数
% e.g.5-4.m for example5-4 to test function of xcov;
clear;
N=256;
f=.1;
t=[0:N-1];
a1=3;
a2=4;
Mlag=N/4;
% Generate two sine waves plus white noise respectively
x=a1*sin(2*pi*f*t)+a2*randn(1,N);
y=a2*sin(2*pi*f*t)+a1*randn(1,N);
subplot(2,2,1);
plot(x(1:N/2));
grid on;
title('Original signal x');
subplot(222);
plot(y(1:N/2));
grid on;
title('Original signal y');
% Estimate the biased autocovariance of random process x
auto_cx=xcov(x,Mlag,'biased');
subplot(223);
plot((-Mlag:Mlag),auto_cx);
title('Autocovariance of x');
% Estimate the biased cross-covariance of random processes x and y
cross_cxy=xcov(x,y,Mlag,'biased');
subplot(224);
plot((-Mlag:Mlag),cross_cxy);
title('Cross-Covariance of x and y');
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?