Why is the look-up table in Simulink must faster than the interp3 function in Matlab script?

3 views (last 30 days)
I'm solving a 6DOF equations of motion of a rigid-body. My code involves 3D interpolation of predefined data. I've implemented the code using both Simulink and Matlab script. In Simulink, the 3D interpolation is carried out by using the 3D look-up table block function while in Matlab the 3D interpolation is performed using the interp3 function. The two sets of results agree well with each other. However, interpolation using interp3 is much slower than the using the look-up table in Simulink. Anyone know the reason? Is there any alternative for interp3 in Matlab which works faster than interp3? Thanks!

Answers (1)

Fangjun Jiang
Fangjun Jiang on 23 Jul 2021
Edited: Fangjun Jiang on 23 Jul 2021
Might it be that interp3() is a M-script function, not a built-in (or written in C) function?
Try to specify all the optional arguments specifically, compile P-code, or generate C code and compile a binary executable.
Or read the interp3.m source code to see if you can use the core function directly and cut some overhead.

Categories

Find more on Simulink in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!