Borrar filtros
Borrar filtros

speed up max function

5 visualizaciones (últimos 30 días)
Chaoyang Jiang
Chaoyang Jiang el 12 de Abr. de 2018
Comentada: Chaoyang Jiang el 13 de Abr. de 2018
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

Respuesta aceptada

dpb
dpb el 12 de Abr. de 2018
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 comentario
Chaoyang Jiang
Chaoyang Jiang el 13 de Abr. de 2018
Thank you very much for your reply.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Variables en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by