필터 지우기
필터 지우기

speed up max function

조회 수: 5 (최근 30일)
Chaoyang Jiang
Chaoyang Jiang 2018년 4월 12일
댓글: Chaoyang Jiang 2018년 4월 13일
How to speed up max function? The following line [a,b] = max(c(1:24,1,2,3)) takes 2685.49s for calling 541390285 times. Is there any way to speed up?
c=randi(100,[24,3,3,3]);
for i=1:1000000
[a,b] = max(c(1:24,1,2,3));
end

채택된 답변

dpb
dpb 2018년 4월 12일
A significant fraction is undoubtedly the addressing of the 4D array; the same fragment but
d=c(1:24,1,2,3);
for i=1:1000000
[a,b] = max(d);
end
cut the time by almost 50%. Whether the real application allows that simplification is unknown, but the concept of reducing the data structure overhead is key one.
  댓글 수: 1
Chaoyang Jiang
Chaoyang Jiang 2018년 4월 13일
Thank you very much for your reply.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Variables에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by