Main Content

Integrate Polyspace Server Products with MATLAB

You can install Polyspace® Bug Finder™ Server™ and Polyspace Code Prover™ Server as standalone products and analyze C/C++ code.

When installing Polyspace server products and MATLAB®, you cannot install MATLAB and Polyspace server products together in a single run of the installer. First install MATLAB by running the MATLAB installer. Then install the Polyspace server product in a different root folder by running the installer separately. For instance, in Windows®:

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

  • Your default Polyspace root folder is C:\Program Files\Polyspace Server\R2024b for the Polyspace server products.

To automate the Polyspace analysis by using MATLAB scripts, integrate the Polyspace server products and MATLAB by running a post-installation step.

Integrate Polyspace Server Products with MATLAB

You can integrate your Polyspace server product with MATLAB only if both installations are from the same release. After the integration, you can use all MATLAB functions and classes available for running Polyspace.

To link your MATLAB and Polyspace installations:

  1. Open MATLAB with administrator privileges.

  2. At the MATLAB command prompt, enter:

    polyspacesetup('install');
    By default, Polyspace is installed in the folder C:\Program Files\Polyspace\R2024b. If you install Polyspace in the default folder, the command integrates Polyspace with MATLAB. If a Polyspace installation is not detected at the default location, provide the path to the Polyspace installation folder when prompted. The process might take a few minutes to complete.

    To avoid the prompt during installation, enter:

    polyspacesetup('install', 'polyspaceFolder', Folder, 'silent', true);

  3. Restart MATLAB. You can now use all functions and classes available for running Polyspace server products.

A MATLAB installation can be integrated with only one Polyspace installation. To integrate to a new Polyspace installation, any previous integration must be removed. To remove the integration between a Polyspace and MATLAB installation, open MATLAB with administrator privilege and at the MATLAB command prompt, enter:

polyspacesetup('uninstall')

Check Integration Between MATLAB and Polyspace

To check if a MATLAB installation is already integrated with a Polyspace installation, open MATLAB and at the command prompt, enter:

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

The MATLAB-Polyspace integration adds some Polyspace installation subfolders to the MATLAB search path. To see which paths were added, enter:

polyspacesetup('showpolyspacefolders')

Run Polyspace Server Products with MATLAB Scripts

In a continuous integration process, you can execute MATLAB scripts that run a Polyspace analysis on new code submissions and compares the results against predefined criteria. Use these functions/classes:

  • Create a polyspace.Project object to configure Polyspace analysis options, run an analysis and read results to MATLAB tables. You can use other MATLAB functions for comparing results against predefined criteria.

    To only read existing results without running an analysis, use the polyspace.BugFinderResults class with the path to a results folder.

  • If you want a more granular selection of checkers for:

    To create a custom target for the analysis and explicitly specify sizes of data types, create a polyspace.GenericTargetOptions object.

You can also use the polyspaceBugFinderServer function to run the analysis and then read results with the polyspace.BugFinderResults class. If you use build commands to build your source code, you can create a Polyspace configuration from the build command using the polyspaceConfigure function.

See Also