⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fg_08_24.m

📁 英文书《Digital Signal Processing with Examples in MATLAB》附带的MATLAB实例
💻 M
字号:
% fg_08_24     Predictive compression - d and e power spectra.
N=6; K=40000; L=K+N;  M=1024;  fs=20;
% Read the signal.
fid=fopen(['signal_2.txt']);
f=fscanf(fid,'%7d%8d%8d%8d%8d%8d%8d%8d%8d%8d\n',L+5000);
fclose(fid);
f=f(5000:L+4999);
% Generate the prediction error. d(k)=s(k); f(k)=s(k-1).
d=f(1:L); f=[0; f(1:L-1)];
Rff=autocovar_mat(f,N);
rfd=crosscovar(f,d,N);
b=Rff\rfd;
e=d-filter(b,1,f);

% Plot spectra of signal and prediction error after startup.
sp_fig(1,9,6);
subplot(2,1,1);
set(gca,'fontsize',16);
d=d(1:K);
[P,nseg,v]=pds(d,d,M,2,.5);
dB=10*log10(max(1,P(1:M/2+1)));
plot(v(1:M/2+1)*fs,dB,'r'); grid on;
ylabel('Power density P_d (dB)');

subplot(2,1,2);
set(gca,'fontsize',16);
e=e(N+1:K);
[P,nseg,v]=pds(e,e,M,2,.5);
dB=10*log10(max(1,P(1:M/2+1)));
plot(v(1:M/2+1)*fs,dB,'b'); grid on;
ylabel('Power density P_e (dB)');
xlabel('Frequency (Hz)');
axis([0 5 -100 50]);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -