DMencode.m
资源名称:work.rar [点击查看]
上传用户:hwtw888
上传日期:2016-03-15
资源大小:177k
文件大小:1k
源码类别:
压缩解压
开发平台:
Matlab
- function y = DMencode(x, a, delt)
- %函数DMencode为德尔塔编码程序,x为要编码的矩阵,a为预测系数,delt为一个正常数。
- %当a默认时,a=1;delt默认时,delt=6.5。
- error(nargchk(1, 3, nargin))
- if nargin < 3
- delt = 6.5
- if nargin < 2
- a = 1;
- end
- end
- x = double(x);
- [m, n] = size(x);
- p = zeros(m, n); %存放预测值
- e = zeros(m, n); %量化前误差
- qe = zeros(m, n); %量化后误差
- ff = zeros(m, n);
- ff(:, 1) = x(:, 1);
- qe(:, 1) = x(:, 1);
- for i = 1: m
- for j = 2: n
- p(i, j) = a.* ff(i, j-1);
- e(i, j) = x(i, j) - p(i, j);
- if e(i, j) > 0
- qe(i, j) = delt;
- else
- qe(i, j) = -delt;
- end
- ff(i, j) = p(i, j) + qe(i, j);
- end
- end
- y = qe;