使用并行计算工具箱™的应用程序可以使用MATLAB中的集群概要文件®选择文件夹。要找到此文件夹,请使用prefdir
。
例如,当您创建一个独立的应用程序时,默认情况下,您的集群配置文件管理器将在应用程序中可用。
应用程序还可以使用外部文件中给出的集群配置文件。为了让你的应用程序使用这个文件,你可以:
链接到代码中的文件。
在运行时传递文件的位置。
使用实例导出集群配置文件到外部文件。
在“Home”选项卡中环境部分中,选择平行>管理集群配置文件。
在集群配置文件管理器对话框,选择一个概要文件,然后在管理部分中,点击出口。
要使应用程序能够使用外部文件中给出的集群配置文件,可以从代码中链接到该文件。在本例中,您将使用绝对路径、相对路径和MATLAB搜索路径链接到集群概要文件。注意,由于每个链接都是在编译之前指定的,所以必须确保每个链接都不会更改。
要为应用程序设置集群配置文件,可以使用setmcruserdata
函数。
由于MATLAB首选项文件夹是与应用程序捆绑在一起的,因此到文件夹内文件的任何相对链接都将始终有效。在应用程序代码中,可以使用myClusterProfile.mlsettings
在MATLAB首选项文件夹中找到的文件如下所示:
mpSettingsPath = fullfile(predir,“myClusterProfile.mlsettings”);setmcruserdata (“ParallelProfile”, mpSettingsPath);
fullfile
给出外部文件的绝对路径。给出的论证mpSettingsPath
必须为绝对路径。如果你的应用程序的用户在他们的文件系统上有一个不会改变的绝对路径的集群配置文件,直接链接到它,如下所示:mpSettingsPath =“/道路/ / myClusterProfile.mlsettings”;setmcruserdata (“ParallelProfile”, mpSettingsPath);
mpSettingsPath = fullfile(pwd,“. . / rel /道路/ / myClusterProfile.mlsettings ');setmcruserdata (“ParallelProfile”, mpSettingsPath);
——一个
在使用世纪挑战集团
添加到MATLAB搜索路径中。因此,您还可以将集群概要文件与外部的应用程序捆绑在一起。首先,使用哪一个
获取集群配置文件的绝对路径。然后,链接到它。mpSettingsPath = which(“myClusterProfile.mlsettings”);setmcruserdata (“ParallelProfile”, mpSettingsPath);
世纪挑战集团——一个/ / myClusterProfile.mlSettings /路径- mmyApp.m;
/ /路径
到你的MATLAB搜索路径。
如果您的应用程序的用户myApp
具有在运行时选择的集群配置文件,您可以在命令行中指定此配置文件。
myApp -mcruserdata ParallelProfile:/path/to/myClusterProfile.mlsettings |
注意,当您使用setmcruserdata
函数的使用,则重写-mcruserdata
国旗。
当你使用setmcruserdata
功能,则删除了使用集群配置文件管理器中可用的任何配置文件的能力。中配置文件的使用集群配置文件管理器,使用parallel.mlSettings
文件。
mpSettingsPath =“/道路/ / myClusterProfile.mlsettings”;setmcruserdata (“ParallelProfile”, mpSettingsPath);%一些应用程序代码origSettingsPath = fullfile(predir,“parallel.mlsettings”);setmcruserdata (“ParallelProfile”, origSettingsPath);%更多应用程序代码
mxArray *key = mxCreateString("ParallelProfile");mxArray *value = mxCreateString("/path/to/myClusterProfile.mlsettings");如果(!setmcruserdata(key, value)) {fprintf(stderr, "无法设置MCR用户数据:\n %s ", mclGetLastErrorMessage());返回1;} |