0

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 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Code generation support for pchip was added in R2014a mathworks.com/help/coder/release-notes.html so if you are using a release before that you may consider upgrading.
Thank you very much libill39 that was it! The solution was upgrading to r2014.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.