I am trying to interpolate values in a 2d space. But my code is very slow.
I used the tic toc and found that it is because of interp2 being called multiple times. Is there an alternate for it ? that would be faster ?

답변 (2개)

Ayush Modi
Ayush Modi 2024년 6월 22일
편집: Ayush Modi 2024년 7월 10일

1 개 추천

Hi,
"griddedInterpolant" function will run faster and is recommended by MathWorks as an alternative to calling "interp2" multiple times.
Refer to the following documentation for more information on "griddedInterpolant" function:

댓글 수: 1

Magnate
Magnate 2024년 7월 17일
Thanks Ayush, griddedInterpolant got the run time to the acceptable range.

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

John D'Errico
John D'Errico 2024년 6월 22일

1 개 추천

Perhaps you are calling interp2 multiple times in a loop, when a single call with multiple points will be far faster. This would be true also with griddedInterpolant. Both tools will be internally optimized to perform much better in a vectorized way.

댓글 수: 1

Magnate
Magnate 2024년 7월 17일
It is not inside a loop. but I will read about vectorized way. thanks.

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

카테고리

도움말 센터File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

질문:

2024년 6월 22일

댓글:

2024년 7월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by