Generate MATLAB Scripts from Polyspace User Interface
You can specify analysis options in the Polyspace® Platform user interface and later generate a MATLAB® script to easily reuse those options.
The user interface provides tooltips, function name autocompletion, context-sensitive help, and other features to help you select the appropriate options. Once you have specified the options, you can generate a MATLAB script. For future analyses, you can modify and run this script without reopening the Polyspace user interface.
Prerequisites
Before you run Polyspace from MATLAB, you must link your Polyspace and MATLAB installations. See Integrate Polyspace with MATLAB and Simulink.
Example Files
This example uses a demo project provided with a Polyspace installation. Inspect the project in the Polyspace Platform user interface:
To open the project, on the toolstrip, select Help > Examples > Prove absence of C runtime errors.
Open the project configuration and note some of the options so that you can compare them later with generated MATLAB scripts. For instance, note that the option Compilation toolchain (Static analysis) is set to
gnu13.x.
Create Scripts from Polyspace Project
To generate MATLAB scripts from the sample project:
Open MATLAB.
Create a
polyspace.Optionsobject from the sample Polyspace project.projectFile = fullfile(polyspaceroot, 'polyspace', 'examples', 'cxx', ... 'Code_Prover_Example', 'Code_Prover_Example.psprj'); opts = polyspace.loadProject(projectFile);
You cannot use the
loadProjectmethod on a project file that is created from a build command by usingpolyspace-configure.Append the object to a MATLAB script.
filePath = opts.toScript('runPolyspace.m','append');
Open the script
runPolyspace.mand look for the option values that you previously noted in the user interface. For instance, you see the compilation toolchain for static analysis:opts.TargetCompiler.Compiler='gnu13.x';Later, you can run the script to recreate the
polyspace.Optionsobject and continue analysis in MATLAB.For more information on running analysis in MATLAB using arun(filePath);
polyspace.Optionsobject, seepolyspace.Options.