Avoid using for loops as it results in ram crash and slow down
조회 수: 2 (최근 30일)
이전 댓글 표시
My code is:
for i = 1:n
for ii = 1:i-1
for iii = 1:ii-1
for iv = 1:iii-1
A = data(l([i ii iii iv 27]), 1:3);
% C(i,ii) = norm(A)*norm(inv(A));
% C(i,ii,iii) = norm(A)*norm(inv(A));
C(i,ii,iii, iv, 1) = cond(A);
% tmp = svd(A, 0);
% C(i,ii,iii,iv) = 0;
% vif{i,ii,iii} = diag(inv(A'*A));
% vif1{i,ii,iii} = diag(inv(A*A'));
end
end
end
i
end
The loop test for only 4 different wavelengths and here I am fixing the the 5th by using 27 in "A = data(l([i ii iii iv 27]), 1:3)", I am interested in adding the fifth as a loop or maybe 6th as well but the problem my ram is crashing and slow down the code a lot.
Any suggestion on how to solve this problem?
Regards,
댓글 수: 5
Walter Roberson
2015년 12월 8일
Only allocate 200*200*200*200*1 as the maximum you use in the final dimension is 1.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!