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

📄 dpcmopt.m

📁 数字通信第四版原书的例程
💻 M
字号:
function [P_trans, codebook, partition] = dpcmopt(training_set, ord, ini_codebook)
%DPCMOPT DPCM parameter optimization using training data.
%       P_TRANS = DPCMOPT(TRAINING_SET, ORD) estimates the predictive transfer
%       function P_TRANS using the given order ORD and the training set
%       TRAINING_SET.
%
%       [P_TRANS,CODEBOOK,PARTITION] = DPCMOPT(TRAINING_SET,ORD,INI_CODEBOOK)
%       produces the optimized predictive transfer function P_TRAINS,  
%       CODEBOOK, and PARTITION for the DPCM. The input variable INI_CODEBOOK
%       can be either a vector that contains the initial estimated value of
%       the codebook vector or a scalar integer that specifies the vector
%       size of CODEBOOK.
%
%       See also LLOYDS.

%       Wes Wang 10/11/94, 10/5/95
%       Copyright (c) 1995-96 by The MathWorks, Inc.
%       $Revision: 1.1 $  $Date: 1996/04/01 17:57:13 $

training_set = training_set(:);
% compute the correlation vectors ri
len = length(training_set);
if len < ord+3
    error('The size of the training set is not large enough for the design in DPCMOPT.')
end;
for i = 1 : ord+2
    r(i) = training_set(1:len-i+1)' * training_set(i:len) / (len - i);
end;

% Levinson-Durbin Algorithm in finding the coeficient for A(z).
P_trans = [1, zeros(1, ord)];
D = r(1);
r = r(:);

for m = 0 : ord-1
    beta = P_trans(1:m+1) * r(m+2:-1:2);
    K = -beta/D;
    P_trans(2 : m+2) = P_trans(2 : m+2) + K * P_trans(m+1 : -1 : 1);
    D = (1 - K*K) * D;
end;

% P = 1 - A(z), the FIR filter for the 
P_trans(1) = 0;
P_trans=-P_trans;


if nargout > 1
    % continue to find the partition and codebook.
    % calculate the predictive errors:
    for i = ord+1 : len
        err(i-ord) = training_set(i) - P_trans * training_set(i:-1:i-ord);
    end;
    % use err for partition and codebook optimization
    [partition, codebook] = lloyds(err, ini_codebook);
end;

% -- end of dpcmopt -- 

⌨️ 快捷键说明

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