interpn return error inside of a Simulink function
9 次查看(过去 30 天)
显示 更早的评论
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 个评论
Vikram Ojha
2022-12-7
Can you please look at this doc https://in.mathworks.com/help/dsp/ref/interpolation.html, if it helps
采纳的回答
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!