Main Content

ConvertMATLABCode to Fixed-Point C Code

To convert MATLAB®Code to fixed-point C Code using theMATLAB Coder™app:

  1. Open theMATLAB Coder应用程序。

  2. On theSelect Source Filespage, add the entry-point function from which you want to generate code.

  3. SetNumeric ConversiontoConvert to fixed point.

  4. ClickNextto go to theDefine Input Typesstep. The app analyzes the function for coding issues and code generation readiness. If the app identifies issues, it opens theReview Code Generation Readinesspage where you can review and fix issues. If the app does not find issues, it opens theDefine Input Typespage.

  5. On theDefine Input Typespage, specify a test file that the app can use to define the input types.

  6. ClickNextto go to theCheck for Run-Time Issuesstep.

  7. On theCheck for Run-Time Issuespage, specify a test file that calls your entry-point function. Alternatively, at the prompt, enter code that calls your entry-point function. The app generates instrumented MEX. It runs the test file or code that you specified, replacing calls to your entry-point function with calls to the generated MEX function. If the app finds issues, it provides warning and error messages. Click a message to highlight the problematic code in a window where you can edit the code.

  8. ClickNextto go to theConvert to Fixed Pointstep.

  9. Propose data types based on simulation range data, derived (also known as static) range data, or both. SeePropose Fixed-Point Data Types Based on Simulation RangesandPropose Fixed-Point Data Types Based on Derived Ranges.

  10. To convert the floating-point MATLAB code to fixed-point MATLAB code, clickConvert. During fixed-point conversion, the app validates the build using the proposed fixed-point data types. SeeValidating Types.

  11. Verify the behavior of the fixed-point MATLAB code. SeeTesting Numerics.

  12. ClickNextto go to theGenerate Codestep.

  13. In theGeneratedialog box, setBuild sourcetoFixed-Point. Set theBuild typeto build a static or dynamic library, or executable. SetLanguageto C. ClickGenerate.

    MATLAB Coder生成entry-p定点C代码oint MATLAB function.

Related Topics