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:
Run a Polyspace analysis on C/C++ code generated from a model or included as custom code in a model from the Simulink Editor. You can also run these analyses using a MATLAB script. See Bug Finder Analysis in Simulink.
If you have Embedded Coder®, run a Polyspace analysis on C/C++ code that is generated from MATLAB code by using the MATLAB Coder App. See Bug Finder Analysis in MATLAB Coder.
Run a Polyspace analysis on hand-written C/C++ code by using MATLAB scripts. See Bug Finder Analysis with MATLAB Scripts.
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
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.
At the MATLAB command prompt, enter the following:
If you installed Polyspace in the default folderpolyspacesetup('install');
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:wherepolyspacesetup('install','polyspaceFolder',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:Folder
polyspacesetup('install', 'polyspaceFolder', Folder, 'silent', true);
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')
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:
The MATLAB or Simulink release supports cross-release integration with a Polyspace release. See Polyspace Support of MATLAB and Simulink from Different Releases.
MATLAB or Simulink is not already integrated with Polyspace.To determine if Polyspace is already integrated, see Check Integration Between MATLAB and Polyspace.
Integrate Polyspace with Cross-Release MATLAB or Simulink
Open MATLAB.
At the MATLAB command prompt, enter:
wherepolyspacesetup('install', 'polyspaceFolder', 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:FOLDER
polyspacesetup('install', 'polyspaceFolder', Folder, 'silent', true);
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')
Check Integration Between MATLAB and Polyspace
To determine if MATLAB is already linked to Polyspace, open MATLAB and enter:
ver
The integration of MATLAB and Polyspace adds Polyspace installation subfolders to the MATLAB search path. To see the added paths, enter:
polyspacesetup('showpolyspacefolders')