M level 2 S-Function TLC file
3 ビュー (過去 30 日間)
古いコメントを表示
Hi everyone, I created a M-S function that can handle N dimension in order to interpolate acording to specific data. Everyhting seems good until
I tried to generate code here were my problems:
- code generator was not able to use "interpn" (i used a maltab fuction in a m file and call it the block function output)
- tried to put everything in a matlab block function , same problem as before.
Here a share main my function, i collect data from a json file and fill my arguments with inside simulink values :
function [Vq_N_D]=interpolationND(jsonfilename,varargin)
end
Here my block Sfunction, for a 3D interpolation (the last part) :
...
function Output(block)
Xq= block.InputPort(1).Data;
Yq = block.InputPort(2).Data;
Zq = block.InputPort(3).Data;
Vq=interpolationND(block.DialogPrm(1).Data,Xq,Yq,Zq);
block.OutputPort(1).Data= Vq;
%endfunction
...
Can anyone help or maybe lead me to a good direction?
0 件のコメント
回答 (1 件)
Manoj Mirge
2023 年 4 月 17 日
Hi,
I am assuming that you are using interpn function with ‘makima’ interpolation method in your S Function. The MATLAB Function block and S Function 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 for code generation.
To resolve your issue, you can try using the makima function, declared as an extrinsic using the coder.extrinsic command. 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
You can read more about how to generate code for functions that are not supported for code generation in the link below:
Hope this helps.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!