使用并行计算工具箱™的应用程序可以使用MATLAB中的群集配置文件®首选项文件夹。要查找此文件夹,请使用前提
。
例如,当您创建独立应用程序时,默认为您提供的所有配置文件集群简介管理器将在申请中提供。
您的应用程序还可以使用外部文件中给出的群集配置文件。要使应用程序能够使用此文件,您可以:
链接到代码中的文件。
在运行时传递文件的位置。
要将群集配置文件导出到外部文件:
在主页选项卡中,在环境部分,选择平行线>管理群集配置文件。
在里面集群简介管理器对话框,选择一个配置文件,并在管理部分,点击出口。
要使应用程序能够使用外部文件中给出的集群配置文件,可以链接到代码中的文件。在此示例中,您将使用绝对路径,相对路径和MATLAB搜索路径链接到群集配置文件。请注意,由于在编译之前指定了每个链接,必须确保每个链接不会更改。
要为应用程序设置群集配置文件,可以使用setmcruserdata.
功能。
当您的Matlab首选项文件夹与您的应用程序捆绑在一起时,文件夹中的文件中的任何相对链接将始终有效。在您的应用程序代码中,您可以使用myclusterprofile.mlsettings.
matlab首选项文件夹中找到的文件如下:
mpsettingspath = fullfile(prefdir,'myclusterprofile.mlsettings');setmcruserdata('并行新闻',mpsettingspath);
fullfile.
给出外部文件的绝对路径。给出的论点Mpsettingspath.
必须是绝对的路径。如果应用程序的用户具有在其文件系统上的集群配置文件,则在绝对路径上不会更改,请直接链接如下:mpsettingspath ='/path/to/myclusterprofile.mlsettings';setmcruserdata('并行新闻',mpsettingspath);
mpsettingspath = fullfile(pwd,'../rel/path/to/myclusterprofile.mlsettings');setmcruserdata('并行新闻',mpsettingspath);
-一种
编译时的标志MCC.
添加到MATLAB搜索路径。因此,您还可以使用外部保存的应用程序捆绑群集配置文件。首先,使用哪一个
获取群集配置文件的绝对路径。然后,链接到它。mpsettingspath =哪个('myclusterprofile.mlsettings');setmcruserdata('并行新闻',mpsettingspath);
MCC.-一种/path/to/myclusterprofile.mlsettings.-M.myapp.m.;
/路径/到/
到您的Matlab搜索路径。
如果您的应用程序的用户myapp.
有一个在运行时选择的群集配置文件,您可以在命令行中指定此功能。
myapp -mcruserdata paralletprofile:/path/to/myclusterprofile.mlsettings |
请注意,当您使用时setmcruserdata.
在代码中的功能,您覆盖了使用的使用-mcruserdata.
旗帜。
当你使用的时候setmcruserdata.
功能,您可以删除使用群集配置文件管理器中可用的任何配置文件的功能。重新启用配置文件集群简介管理器, 使用并行.mlsettings.
文件。
mpsettingspath ='/path/to/myclusterprofile.mlsettings';setmcruserdata('并行新闻',mpsettingspath);%某些应用程序代码origsettingspath = fullfile(prefdir,'并行.mlsettings');setmcruserdata('并行新闻',OIGSETTINGSPATH);%更多的应用程序代码
mxarray * key = mxcreatestring(“parallateProfile”);mxarray * value = mxcreatestring(“/ path / to / myclusterprofile.mlsettings”);if(!setmcruserdata(key,value)){fprintf(stderr,“无法设置MCR用户数据:\ n%s”,mclgetlasterRormessage());返回-1;} |