0001 function z=nt_multiscale(x,depth,p)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 if nargin<3||isempty(p); p=1; end
0013 if nargin<2; error('!'); end
0014
0015 if ndims(x)==3;
0016 [m,n,o]=size(x);
0017 z=zeros(m-2^depth-1,n*depth,o);
0018 for k=1:o
0019 z(:,:,k)=nt_multiscale(x(:,:,k),depth);
0020 end
0021 return
0022 end
0023
0024 [m,n]=size(x);
0025 z=zeros(m,n,depth);
0026
0027 z(:,:,1)=x(1:size(z,1),:);
0028 for k=1:depth-1
0029 step=2^k-1;
0030 step=floor(step.^p);
0031 idx=1:(m-step);
0032 z(idx,:,k+1) = (...
0033 z(idx,:,k) + ...
0034 z(idx+step,:,k) )/2;
0035 end
0036 z=z(1:end-step,:,:);
0037
0038