0
$\begingroup$

I am currently working on an audio watermarking project in MATLAB. I currently have a code I am using to construct a nxn 3 Band Wavelet Transform matrix. However, when I try to construct a matrix that is larger in size, I get the error "Maximum variable size allowed by the program is exceeded" or "Out of Memory."

Therefore, I was wondering if someone would be able to tell me what may be the cause of this problem and if there is an exisiting code or toolbox that could construct a 3 Band Wavelet Transform Matrix better and more efficiently. Thank you!

The following is the code I am trying to use. I am trying to create a matrix that is the size 3^9 X 3^9 and 3^10 X 3^10.

prompt = {'Enter Matrix Power: '};
dlg_title = 'Matrix Power';
answer = inputdlg(prompt,dlg_title);
n = str2num(answer{1});  %#ok<ST2NM>

A=zeros(3^(n-1),3^n);
v=[0.338386097283860 0.530836187013740 0.723286276743610 0.238964171905760 0.0465140821758900 -0.145936007553990 ];
w1=[-0.117377016134830 0.54433105395181 -0.0187057473531300 -0.699119564792890 -0.136082763487960 0.426954037816980 ];
w2=[0.403636868928920 -0.628539361054710 0.460604752521310 -0.403636868928920 -0.0785674201318500 0.246502028665230 ];
for j=1:3^(n-1)-1 
    for k=1:3^n;
        if k>6+3*(j-1) || k<=3*(j-1)
            A(j,k)=0;
        else 
            A(j,k)=v(k-3*(j-1));
        end                
    end
end
j=3^(n-1);
    for k=1:3^n
        if k<=3
            A(j,k)=v(k+3);
        elseif k<=3^n-3
            A(j,k)=0;
        else 
            A(j,k)=v(k-3*(j-1));
        end
    end

B=zeros(3^(n-1),3^n);
for j=1:3^(n-1)-1
    for k=1:3^n
        if k>6+3*(j-1) || k<=3*(j-1)
            B(j,k)=0;
        else
            B(j,k)=w1(k-3*(j-1));
        end
    end
end
j=3^(n-1);
    for k=1:3^n
        if k<=3
            B(j,k)=w1(k+3);
        elseif k<=3^n-3
            B(j,k)=0;
        else
            B(j,k)=w1(k-3*(j-1));
        end
    end
C=zeros(3^(n-1),3^n);
for j=1:3^(n-1)-1
    for k=1:3^n
        if k>6+3*(j-1) || k<=3*(j-1)
            C(j,k)=0;
        else
            C(j,k)=w2(k-3*(j-1));
        end
    end
end
j=3^(n-1);
     for k=1:3^n
         if k<=3
             C(j,k)=w2(k+3);
         elseif k<=3^n-3
             C(j,k)=0;
         else
             C(j,k)=w2(k-3*(j-1));
         end
     end
W=[A;B;C];
Q=zeros(3^n,3^n);
T=zeros(3^n,3^n);
$\endgroup$
  • $\begingroup$ It would be helpful if you showed the part of the code which causes the error. What is the size of the matrix? $\endgroup$ – Matt L. Jun 30 '13 at 18:03
  • $\begingroup$ I edited my question to show the code. I am trying to make a matrix size 3^9 X 3^9 and 3^10 X 3^10. $\endgroup$ – Math244 Jun 30 '13 at 20:52
  • 1
    $\begingroup$ For a matrix of size $3^9\times 3^9$ you need about 3GB of memory (assuming double precision). A matrix of size $3^{10}\times 3^{10}$ needs about 28GB of memory. This is clearly too much for most systems. $\endgroup$ – Matt L. Jun 30 '13 at 21:05
  • $\begingroup$ Wow okay so 3^10 is obviously much too big to do on a standard system. As I am working with audio watermarking, do you recommend breaking the audio signal into frames sized to the maximum size I can make my wavelet transform matrix and working from there? I guess the max size would be 3^9. $\endgroup$ – Math244 Jul 1 '13 at 14:37
  • $\begingroup$ @BobbyDolan: Yes, this is simply an error for "you're trying to do more than I can fit in your machine's memory", and you have to avoid it by breaking up the signal into smaller pieces and working on each at a time (or using some kind of virtual memory/swap to disk if matlab supports that) $\endgroup$ – endolith Jul 1 '13 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.