function [Lo_D,Hi_D,Lo_R,Hi_R] = wmakebases(wname,level)
[Lo_D,Hi_D,Lo_R,Hi_R] = wfilters(wname);
if level ==1
    return ;
end

% these are 1-level bases
Lo_D0=Lo_D;
Lo_R0=Lo_R;
Hi_D0=Hi_D;
Hi_R0=Hi_R;

for i=1:level-1
    k=2^i;
    len=length(Lo_D0)-1;
    len1=length(Lo_D);
    
    scalebase_D=zeros(1, k*len+len1);
    %current level base len=2^(previous level)*(length 1-level
    %base-1)+length of previous base

    %remember: current approx=1-level approx base dot product over previous
    %approx(trend) or Lo_D
    for i=0:len
        scalebase_D(k*i+1:k*i+len1)=Lo_D0(i+1)*Lo_D+scalebase_D(k*i+1:k*i+len1);
    end
    %remember: current detail=1-level detail base dot product over previous
    %approx(trend) or Lo_D
    waveletbase_D=zeros(1, k*len+len1);
    for i=0:len
        waveletbase_D(k*i+1:k*i+len1)=Hi_D0(i+1)*Lo_D+waveletbase_D(k*i+1:k*i+len1);
    end
    scalebase_R=zeros(1, k*len+len1);
    for i=0:len
        scalebase_R(k*i+1:k*i+len1)=Lo_R0(i+1)*Lo_R+scalebase_R(k*i+1:k*i+len1);
    end
    waveletbase_R=zeros(1, k*len+len1);
    for i=0:len
        waveletbase_R(k*i+1:k*i+len1)=Hi_R0(i+1)*Lo_R+waveletbase_R(k*i+1:k*i+len1);
    end
    Lo_D=scalebase_D;
    Hi_D=waveletbase_D;
    Lo_R=scalebase_R;
    Hi_R=waveletbase_R;
end
return ;