Personnal explaination of Appcoef.m

Explaination of Appcoef

function a = appcoef(c,l,varargin)

%APPCOEF Extract 1-D approximation coefficients.

%   APPCOEF computes the approximation coefficients of a

%   one-dimensional signal.

%

%   A = APPCOEF(C,L,'wname',N) computes the approximation

%   coefficients at level N using the wavelet decomposition

%   structure [C,L] (see WAVEDEC).

%   'wname' is a string containing the wavelet name.

%   Level N must be an integer such that 0 <= N <= length(L)-2.

%

%   A = APPCOEF(C,L,'wname') extracts the approximation

%   coefficients at the last level length(L)-2.

%

%   Instead of giving the wavelet name, you can give the filters.

%   For A = APPCOEF(C,L,Lo_R,Hi_R) or

%   A = APPCOEF(C,L,Lo_R,Hi_R,N),

%   Lo_R is the reconstruction low-pass filter and

%   Hi_R is the reconstruction high-pass filter.

%   

%   See also DETCOEF, WAVEDEC.

 

%   M. Misiti, Y. Misiti, G. Oppenheim, J.M. Poggi 12-Mar-96.

%   Last Revision: 06-Feb-2011.

%   Copyright 1995-2015 The MathWorks, Inc.

% explainer Damon Yan 2017/11/15(there are also some problems that the writer can not understand clearly,such as the iteration to compute the approximation of signals,so welcome for the advices and discussion)

 

% Check arguments.

% check the number of variable,if it isnt between 2 to 5,then the function returns false 0.

 

narginchk(2,5)

% rmax is the length of l

rmax = length(l);

% nmax is the maximum level of decomposition

nmax = rmax-2;

if ischar(varargin{1}) %the first input variable is a char?

% True! { I.e:db,then [LO_D,HI_D,LO_R,HI_R] = WFILTERS('wname') }

% false! {Lo_R = varargin{1}; Hi_R = varargin{2};}

    [Lo_R,Hi_R] = wfilters(varargin{1},'r'); next = 2;

else

    Lo_R = varargin{1}; Hi_R = varargin{2};  next = 3;

end

% if the decomposition level N is defined, then

% execute this number; if not, then the signal is

% decomposed to the maximum level.  

if nargin>=(2+next) , n = varargin{next}; else n = nmax; end

% the decomposition level should be N integer between o and nnmax.

if (n < 0) || (n > nmax) || (n ~= fix(n))

    error(message('Wavelet:FunctionArgVal:Invalid_LevVal'));

end

 

% Initialization(aN).

a = c(1:l(1));

 

% Iterated reconstruction.

imax = rmax+1;

for p = nmax:-1:n+1

    d = detcoef(c,l,p);                % extract detail

    a = idwt(a,d,Lo_R,Hi_R,l(imax-p));

end

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值