How can I reduce the run time a code?

6 visualizaciones (últimos 30 días)
Abdullah Türk
Abdullah Türk el 22 de Dic. de 2023
Comentada: Abdullah Türk el 22 de Dic. de 2023
Hi everybody,
I ran a code and controlled the run time of each script.
As you can see in Figure attachment, I realized that find command increase the run time.
How can I reduce this time?

Respuestas (2)

madhan ravi
madhan ravi el 22 de Dic. de 2023
Movida: Matt J el 22 de Dic. de 2023
Directly use logical indexing , i.e: remove find(…) command and replace your if condition with
if any(index)
Try using ismember(…) instead of == , not sure which one is faster.

Matt J
Matt J el 22 de Dic. de 2023
Editada: Matt J el 22 de Dic. de 2023
Replace the whole for-loop over y with,
index_control=ismember(aktivite1, aktivite2);
m=find(index_control,1);
index_control(m+1:end)=0;
bxf2(j)=~isempty(m);
  1 comentario
Abdullah Türk
Abdullah Türk el 22 de Dic. de 2023
Matt J thanks but it increased the time. Thanks a lot for your response.

Iniciar sesión para comentar.

Productos


Versión

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by