How to convert matlab function 'pchip' to c code with matlab coder

我们两清 提交于 2020-01-06 07:25:23

问题


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 with NaN values.
  • If you generate code for the pp = pchip(x,y) syntax, you cannot input pp to the ppval function in MATLAB. To create a MATLAB pp structure from a pp 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!