MATLAB: Out of memory. Type HELP MEMORY for your options.

MATLABout of memory

Hi, Please find below code.It gives Out of memory. HELP MEMORY for your options.Error in ndgrid (line 66) x = reshape(x(:,ones(1,prod(s))),[length(x) s]); . Please help me resolving this.
Thanks, Sita
clc; clear; tic p = haltonset(1) %'Skip',1e3,'Leap',1e2);
i1=1; j1=10;
i2=1; j2=10;
i3=1; j3=10;
i4=1; j4=10;
i5=1; j5=10;
i6=1; j6=10;
i7=1; j7=10;
i8=1; j8=10;
i9=1; j9=10;
i10=1; j10=10;
x1s(:,:)=p(i1:j1,:); x2s(:,:)=p(i2:j2,:); x3s(:,:)=p(i3:j3,:); x4s(:,:)=p(i4:j4,:); x5s(:,:)=p(i5:j5,:); x6s(:,:)=p(i6:j6,:); x7s(:,:)=p(i7:j7,:); x8s(:,:)=p(i8:j8,:); x9s(:,:)=p(i9:j9,:); x10s(:,:)=p(i10:j10,:);
[aa bb cc dd ee ff gg hh ii jj]=ndgrid(x1s,x2s,x3s,x4s,x5s,x6s,x7s,x8s,x9s,x10s);
overnested = arrayfun(@(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10)[x1,x2,x3,x4,x5,x6,x7,x8,x9,x10],aa,bb,cc,dd,ee,ff,gg,hh,ii,jj,'un',0);
celldisp(overnested)
x = permute([aa(:), bb(:),cc(:),dd(:),ee(:),ff(:),gg(:), hh(:),ii(:),jj(:)],[ 11 10 9 8 7 6 5 4 3 2 1]);%replaced below code
x1temp=x(1,1,1,1,1,1,1,1,1,1,:)
x2temp=x(1,1,1,1,1,1,1,1,1,2,:)
x3temp=x(1,1,1,1,1,1,1,1,1,3,:)
x4temp=x(1,1,1,1,1,1,1,1,1,4,:)
x5temp=x(1,1,1,1,1,1,1,1,1,5,:)
x6temp=x(1,1,1,1,1,1,1,1,1,6,:)
x7temp=x(1,1,1,1,1,1,1,1,1,7,:)
x8temp=x(1,1,1,1,1,1,1,1,1,8,:)
x9temp=x(1,1,1,1,1,1,1,1,1,9,:)
x10temp=x(1,1,1,1,1,1,1,1,1,10,:)

Best Answer

All possible permutations in a loop:
for ii = 1:numel(x1)
for jj = 1:numel(x2)
for kk = 1:numel(x3)
your_input = [x1(ii) x2(jj) x3(kk)]
end
end
end
This could help with your out of memory error. Depending on the sizes of the vector it might take a long time. Please accept an answer if it helps you.
Related Question