主要内容

polyspaceroot

获取 Polyspace 安装文件夹

说明

polyspaceroot 返回 Polyspace® 的安装文件夹。

从 R2019a 开始,要运行 MATLAB® 脚本进行 Polyspace 分析,请将 MATLAB 和 Polyspace 安装在不同的文件夹中,并在它们之间建立链接。在安装并链接后,要从 MATLAB 访问 Polyspace 安装文件夹中的文件,请使用此函数。另请参阅将 Polyspace 与 MATLAB 和 Simulink 集成将 Polyspace Server 产品与 MATLAB 集成

示例

示例

全部折叠

要确定 Polyspace 安装文件夹,请使用 polyspaceroot 函数。

polyspaceroot
C:\Program Files\Polyspace\R2019a

对于产品 Polyspace Bug Finder™ Server™Polyspace Code Prover™ Server,在 Windows® 中,默认安装文件夹为:

C:\Program Files\Polyspace Server\R2019a

要访问 Polyspace 安装文件夹中的示例文件,请使用 polyspaceroot 函数获取安装文件夹的根目录。使用 fullfile 函数将子文件夹追加到根文件夹路径。

对 Polyspace 安装文件夹的子文件夹 polyspace\examples\cxx\Bug_Finder_Example\sources 中的文件 numerical.c 运行 Bug Finder。

proj = polyspace.Project

% Specify sources and includes
sourceFile = fullfile(polyspaceroot, 'polyspace', ... 
    'examples', 'cxx', 'Bug_Finder_Example', 'sources', 'numerical.c');
includeFolder = fullfile(polyspaceroot, 'polyspace', ... 
    'examples', 'cxx', 'Bug_Finder_Example', 'sources');

% Configure analysis
proj.Configuration.Sources = {sourceFile};
proj.Configuration.TargetCompiler.Compiler = 'gnu4.9';
proj.Configuration.EnvironmentSettings.IncludeFolders = {includeFolder};
proj.Configuration.ResultsDir = fullfile(pwd,'results');

% Run analysis
bfStatus = proj.run('bugFinder');

版本历史记录

在 R2019a 中推出