📄 ar_yule_walker.m
字号:
clear all
clc
%----------Generate the signal with noise------%
N=32;
f1=0.21;
f2=0.23;
phi1=unifrnd(0,2*pi);
phi2=unifrnd(0,2*pi);
a1=1;
a2=1;
var=sqrt(((a1^2)/2+(a2^2)/2)/10);
n=0:1:N-1;
wk=var*rand(1,N);
xn=a1*sin(2*pi*f1*n+phi1)+a2*sin(2*pi*f2*n+phi2)+wk;
%----------figure the wave of signal----------%
subplot(211);
plot(xn);
xlabel('n');
ylabel('xn');
title('随机序列');
%----------calculate the PSD of the sequence by Yuler_Walker ----%
p=floor(length(xn)/3)+1;
nfft=1024;
[xpsd,f]=pyulear(xn,p,nfft,1);
pmax=max(xpsd);
xpsd=xpsd/pmax;
xpsd=10*log10(xpsd);
subplot(212);
%f=f/max(f);
plot(f,xpsd);
title('Yule-Walker PSD');
ylabel('功率谱密度(dB)');
xlabel('频率(Hz)');
grid on;
% ymin=min(xpsd)-2;
% ymax=max(xpsd)+2;
% axis(ymin,ymax);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -