Hi all I am applying a alogorithm after computing the gradient I am getting an error.My code is
maxgrad=sqrt(double(gradscalex.*gradscalex+gradscaley.*gradscaley)); [gradscale gidx]=max(maxgrad,,3); gxtemp=zeros(M,N); gytemp=gxtemp; for kn=1:K [rowidx colidx ]=ind2sub(size(gidx),find(gidx==kn)); gxtemp(rowidx,colidx)=gradscalex(rowidx,colidx,kn); gytemp(rowidx,colidx)=gradscaley(rowidx,colidx,kn); end gradscalex=gxtemp; gradscaley=gytemp;
??? Maximum variable size allowed by the program is exceeded.
Error in ==> Untitled at 36 gxtemp(rowidx,colidx)=gradscalex(rowidx,colidx,kn); Help me plz to solve this problem.I searched out but no solution.I am using Matlab version 7.11.0(R2010b) with 32-Bit operating system and 4GB RAM.
No products are associated with this question.
I have the vague impression that you're trying to do this:
[M,N,P]=size(gradscalex); [mm,nn]=ndgrid(1:M,1:N); %pre-compute once!!
maxgrad=sqrt(double(gradscalex.*gradscalex+gradscaley.*gradscaley)); [~, gidx]=max(maxgrad,,3); idx=sub2ind([M,N,P],mm(:),nn(:),gidx(:));
gxtemp=reshape( gradscalex(idx) ,[M,N]); gytemp=reshape( gradscaley(idx) ,[M,N]);
Probably the simplest way to debug this is to set a breakpoint with
>> dbstop if error
before you run the code. Then, run your code. It will halt execution when it hits the error, and bring you to the editor automatically.
My guess is that you will find that one (or both) of the variables "rowidx" or "colidx" are much, much larger than you expect, and the offending line is therefore attempting to create a huge array.
After you are done debugging, you might want to clear the breakpoint with
>> dbclear if error
Play games and win prizes!Learn more