Main Content

Integrate Polyspace with MATLAB and Simulink

Polyspace® Bug Finder™ and Polyspace Code Prover™ are standalone products. Install these Polyspace products by using the MathWorks® installer. See Install Polyspace with Other MathWorks Products.

Polyspace products are installed in a different root folder from other MathWorks products. For instance, in Windows®:

  • The default MATLAB® root folder is C:\Program Files\MATLAB\R2024b.

  • The default Polyspace root folder is C:\Program Files\Polyspace\R2024b.

To run Polyspace from MATLAB, Simulink®, or MATLAB Coder™, perform a post-installation procedure to integrate Polyspace with MATLAB and Simulink.

The integration process and supported MATLAB releases might be different for previous Polyspace releases. Check the documentation of your release if you have Polyspace from an older release.

Same Release of Polyspace and MATLAB

If Polyspace and MATLAB are both from the same release, you can do the following after integrating Polyspace and MATLAB:

Prerequisite

Before you integrate Polyspace with MATLAB or Simulink from the same release, determine if your MATLAB or Simulink is already integrated with Polyspace. See Check Integration Between MATLAB and Polyspace.

Integrate Polyspace with MATLAB or Simulink

  1. Open MATLAB with administrator or root privileges. For instance, in Windows, to open MATLAB with administrator privilege, right-click the MATLAB executable and select Run as administrator.

  2. At the MATLAB command prompt, enter the following:

    polyspacesetup('install');
    If you installed Polyspace in the default folder C:\Program Files\Polyspace\R2024b, the command integrates Polyspace with MATLAB. If a Polyspace installation is not detected at the default location, you are prompted for the installation location. Alternatively, use:
    polyspacesetup('install','polyspaceFolder',Folder)
    where Folder is the Polyspace installation folder. If you are prompted that the workspace will be cleared and that all open models closed, click Yes. The process might take a few minutes to complete. To avoid interactive prompts, enter:
    polyspacesetup('install', 'polyspaceFolder', Folder, 'silent', true);

  3. Restart MATLAB.

You can also perform the integration by using a script. See Integrate Polyspace Noninteractively with MATLAB at Command Line by Using -batch.

Unlink and Relink MATLAB and Polyspace

You can integrate MATLAB with only one instance of Polyspace. To integrate with a different instance of Polyspace, uninstall the current integration. At the MATLAB command prompt, enter:

polyspacesetup('uninstall')
This step uninstalls only the integration between MATLAB and Polyspace. To uninstall an instance of Polyspace, use the MathWorks installer.

MATLAB Release Earlier Than Polyspace

You can also integrate Polyspace with MATLAB or Simulink from an earlier release. This cross-release integration offers limited functionalities compared to the same-release integration. In a cross-release workflow:

  • You can run a Polyspace analysis of generated C/C++ code in the MATLAB Command Window.

  • You cannot analyze custom code included in models or handwritten code.

  • You cannot start Polyspace analyses from the Simulink Editor or MATLAB Coder App.

See Polyspace Support of MATLAB and Simulink from Different Releases.

Prerequisite

To perform a cross-release integration, these conditions must be true:

Integrate Polyspace with Cross-Release MATLAB or Simulink

  1. Open MATLAB.

  2. At the MATLAB command prompt, enter:

    polyspacesetup('install', 'polyspaceFolder', Folder)
    where FOLDER is the Polyspace installation folder. If you are prompted that the workspace will be cleared and that all open models closed, click Yes. The process might take a few minutes to complete. To avoid interactive prompts, enter:
    polyspacesetup('install', 'polyspaceFolder', Folder, 'silent', true);

  3. Restart MATLAB.

In addition to using a command line prompt, you can also perform the integration by using a script. See Integrate Polyspace Noninteractively with MATLAB at Command Line by Using -batch.

You can integrate MATLAB with only one instance of Polyspace. To integrate with a different instance of Polyspace, uninstall the current integration. At the MATLAB command prompt, enter:

polyspacesetup('uninstall')
This step uninstalls only the integration between MATLAB and Polyspace. To uninstall an instance of Polyspace, use the MathWorks installer.

Check Integration Between MATLAB and Polyspace

To determine if MATLAB is already linked to Polyspace, open MATLAB and enter:

ver
If Polyspace is integrated with MATLAB, you see the Polyspace products in the list of installed products.

The integration of MATLAB and Polyspace adds Polyspace installation subfolders to the MATLAB search path. To see the added paths, enter:

polyspacesetup('showpolyspacefolders')

See Also

Related Topics