How can I reduce the run time a code?

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?

답변 (2개)

madhan ravi
madhan ravi 2023년 12월 22일
이동: Matt J 2023년 12월 22일

1 개 추천

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 2023년 12월 22일
편집: Matt J 2023년 12월 22일

0 개 추천

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

Abdullah Türk
Abdullah Türk 2023년 12월 22일
Matt J thanks but it increased the time. Thanks a lot for your response.

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

카테고리

제품

릴리스

R2015a

질문:

2023년 12월 22일

댓글:

2023년 12월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by