interpn return error inside of a Simulink function

조회 수: 3 (최근 30일)
olbond
olbond 2022년 12월 7일
댓글: olbond 2022년 12월 9일
Hi,
I whish to do N-D interpolation in the Simulink (R2022a), so I put interpn function with required arguments and inputs inside of Matlab Function block, however if I use option 'makima', Simulink return the following error: 'Invalid interpolation type specified'.
The same function with the same arguments, option and inputs work well in Matlab workspace.
Are there any limitations on methods implemented in interpn function when using in Simulink?
Thank you.

채택된 답변

Stephen Eltinge
Stephen Eltinge 2022년 12월 7일
Hi olbond,
The MATLAB Function block only supports the subset of MATLAB language features that are compatible with C/C++ code generation. The interpn function does not support the 'makima' interpolation method for code generation, so you cannot use it in a MATLAB Function block out of the box.
Here are two different approaches to resolving this issue:
1) If it's important to exactly reproduce a workflow from the MATLAB workspace, try using the makima function, declared as an extrinsic using the coder.extrinsic command (example). Your MATLAB Function block's code might look something like this:
function y = fcn(u)
coder.extrinsic('makima');
y = 0;
y = makima(1:10, 1:10, u);
end
2) If you want to take advantage of the full range of Simulink features, consider expressing your computation in block diagram form using the n-D Lookup Table block. It can perform interpolation using Akima splines, among other methods.
  댓글 수: 1
olbond
olbond 2022년 12월 9일
Hi Stephen,
Thank you for reply and comment.
I got it.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 User-Defined Functions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by