Main Content

Configure Advanced Polyspace Options for Code Generated Using MATLAB Coder

Before analyzing generated code with Polyspace®, you can change some of the default options. This topic shows how to configure a Polyspace analysis of code generated from MATLAB® code and reuse the configuration.

In R2025a: Polyspace does not integrate with the new MATLAB Coder™ app. Use MATLAB scripts to configure your Polyspace analysis. See Run Polyspace on C/C++ Code Generated from MATLAB Code

Configure Polyspace Options

The default Polyspace analysis runs a Polyspace Code Prover™ analysis based on a default project configuration. The results are stored in a folder named result_project_name in the current working folder. When analyzing generated code, you can change these options by using a pslinkoptions object:

opts = pslinkoptions('ec');
Use the properties of the opts object to configure your analysis. For example:

  • Choose between Bug Finder and Code prover:

    % Run Code Prover
    opts.VerificationMode = 'CodeProver';
    % Run Bug Finder
    opts.VerificationMode = 'BugFinder';

  • When running Bug Finder, check for violations of MISRA C: 2012 coding rules in addition to the checkers configured in your project (.psprj) file.:

    opts.VerificationSettings = 'PrjConfigAndMisraC2012';

  • Choose an output folder name and location:

    opts.ResultDir = '\results_v1'
    To save the results of each run in a new folder, make output folder name unique by adding a suffix:
    opts.AddSuffixToResultDir = true;

  • Choose to see warnings or errors if MATLAB Coder uses options that can result in imprecise Code Prover analysis:

    opt.CheckConfigBeforeAnalysis = 'OnWarn';

    For instance, if the code generation setting Use memset to initialize floats and doubles to 0.0 is disabled, Code Prover can show imprecise orange checks because of approximations. See Orange Checks in Polyspace Code Prover.

For more information on the options, see pslinkoptions.

Share and Reuse Configuration

You can configure advanced Polyspace options in a Polyspace project file (psprj). This project file can be used to share Polyspace configuration between different Polyspace analyses.

To use configuration from a psprj file when analyzing generated code, use the properties EnablePrjConfigFile and PrjConfigFile:

opts.EnablePrjConfigFile = true;
opts.PrjConfigFile = 'C:\Polyspace\config.psprj';
For more information, see pslinkoptions.

See Also

Topics