interpn return error inside of a Simulink function
12 views (last 30 days)
Show older comments
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.
1 Comment
Vikram Ojha
on 7 Dec 2022
Can you please look at this doc https://in.mathworks.com/help/dsp/ref/interpolation.html, if it helps
Accepted Answer
Stephen Eltinge
on 7 Dec 2022
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.
More Answers (0)
See Also
Categories
Find more on Simulink Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!