问题
I have a problem with Matlab Coder. I would like to generate C code from Matlab interpolating function pchip
. I verified the function with coder.screener
and it says it's available for code generation but when I try to build pchip.m
file I get this error:
The function 'pchip' is not supported for standalone code generation. See the documentation for coder.extrinsic to learn how you can use this function in simulation.
Can anyone help me? I really need to convert this function in C for a program I am writing.
回答1:
Limitations of pp = pchip(x,y)
for code generation from the documentation:
- Input
x
must be strictly increasing. - Does not remove
y
entries withNaN
values. - If you generate code for the
pp = pchip(x,y)
syntax, you cannot inputpp
to theppval
function in MATLAB. To create a MATLABpp
structure from app
structure created by the code generation software:- In code generation, use unmkpp to return the piecewise polynomial details to MATLAB.
- In MATLAB, use mkpp to create the
pp
structure.
So, please check that you fulfill the previous points; especially the last one. You have examples in the documentation of how to make/unmake a picewise polynomial.
来源:https://stackoverflow.com/questions/23229744/how-to-convert-matlab-function-pchip-to-c-code-with-matlab-coder