interpn return error inside of a Simulink function
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
olbond
am 7 Dez. 2022
Kommentiert: olbond
am 9 Dez. 2022
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 Kommentar
Vikram Ojha
am 7 Dez. 2022
Can you please look at this doc https://in.mathworks.com/help/dsp/ref/interpolation.html, if it helps
Akzeptierte Antwort
Stephen Eltinge
am 7 Dez. 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Simulink Functions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!