parsim
并行或串行多次模拟动态系统
Syntax
描述
SIMulates a model using the inputs specified in theSIMOut
= parsim(在
)仿真input
对象,in。parsim
命令使用一个数组仿真input
对象运行多个模拟。
SIMulates a model in parallel using the inputs specified in theSIMOut
= parsim(在
,“显示模仿者”
,'on'
)仿真input
对象并打开模拟管理器UI。有关更多信息,请参阅模拟管理器
.
SIMulates a model in parallel using the inputs specified in theSIMOut
= parsim(在
,名称,价值
)仿真input
object and the options specified as the名称,价值
pair.
Theparsim
命令使用并行计算工具箱™许可并行运行模拟。parsim
如果无法创建并行计算工具箱,则在串行中运行模拟。
例子
Usingparsim
with Rapid Accelerator
Simulate the model,VDP
,以快速加速器模式。
加载模型。
model ='vdp';LOAD_SYSTEM(型号)
This step builds the Rapid Accelerator target
万博1manbetxsimulink.blockdiagram.buildrapidacceleratortarget(模型);
Create a仿真input
对象和使用setModelParameter
设置的方法RapidAcceleratorUpToDateCheck
to'离开'
.
in = 万博1manbetxsimulink.simulationInput(模型);in = in.setModelParameter(“SimulationMode”,'rapid-accelerator');in = in.setModelParameter(“ RapidAcceleratoruptoptatecheck”,'离开');
Simulate the model.
out = parsim(in)
与Parsim并行模拟模型
Simulate the model, CSTR, in parallel by sweeping over a variable. An array of SimulationInput objects is used to perform the sweep.
指定扫描值。
FeedTempSweep = 250:10:300;
Create an array of SimulationInput objects.
fori = length(FeedTempSweep):-1:1 in(i) = Simulink.SimulationInput('cstr');在(i)= in(i).setVariable('feedTemp0',feedTempsweep(i));结尾
并联模拟模型。
out = parsim(in,'ShowProgress','on')
[11-Dec-2020 09:14:55] Checking for availability of parallel pool... Starting parallel pool (parpool) using the 'local' profile ... Connected to the parallel pool (number of workers: 6). [11-Dec-2020 09:15:43] Starting Simulink on parallel workers... [11-Dec-2020 09:16:17] Configuring simulation cache folder on parallel workers... [11-Dec-2020 09:16:17] Loading model on parallel workers... [11-Dec-2020 09:16:25] Running simulations... [11-Dec-2020 09:16:58] Completed 1 of 6 simulation runs [11-Dec-2020 09:16:58] Completed 2 of 6 simulation runs [11-Dec-2020 09:16:58] Completed 3 of 6 simulation runs [11-Dec-2020 09:17:00] Completed 4 of 6 simulation runs [11-Dec-2020 09:17:01] Completed 5 of 6 simulation runs [11-Dec-2020 09:17:01] Completed 6 of 6 simulation runs [11-Dec-2020 09:17:02] Cleaning up parallel workers... out = 1x6 Simulink.SimulationOutput array
输入参数
在
—万博1manbetxSimulink.SimulationInput
用于模拟模型的对象
对象,数组
A万博1manbetxSimulink.SimulationInput
对象或一个数组万博1manbetxSimulink.SimulationInput
用于指定模型更改的对象。
例子:in = 万博1manbetxsimulink.simulationInput('vdp')
Name-Value Arguments
例子:'ShowProgress'
,'on'
Note
All parameters passed toparsim
命令与与SIM
command. To pass to theparsim
命令,使用以下输入参数的列表
指定可选的逗号分隔对名称,价值
参数。Name
是参数名称和价值
是相应的值。Name
和价值
必须出现在单引号中(' '
)。您可以按任何顺序指定几个名称和值对参数NAME1,Value1,...,Namen,Valuen
.
附加的文件
—Files to attach to parallel pool
单元阵列
指定为附加文件的单元格数组,以连接到并行池。
表演
—显示模拟的进度
'on'(default)|'离开'
Set to'on'
, to see the progress of the simulations in the command window. The progress is hidden when set to'离开'
.
Note
什么时候the progress is shown, a message“清理平行工人..”
may be displayed before the completion of the last few simulations. This message does not depend on the completion of the simulations. Simulations complete when the outputs are fetched from the未来
. For more information, see万博1manbetxsimulink.simulation.future
.
RunInBackground
—在后台运行模拟
'离开'(default) |'on'
Set to'on'
to run simulations asynchronously, keeping the MATLAB®command prompt available for use.
设置
—Function handle to run once per worker
function handle
指定function handle
to'setupfcn'
to run once per worker before the start of the simulations.
例子:'setupfcn',@()currentProject('modelex/model_example.prj')
Note
什么时候buildrapidacceleratortarget
在设置中使用,该模型已指定了外部输入,要么设置“ loadexternalInput”
to'离开'
或确保在工人上可用指定的外部输入以防止编译错误。
清理
—运行模拟后,每个工人的功能句柄要运行一次
function handle
指定function handle
to'CleanupFcn'
模拟完成后,每个工人一次运行一次。
托管依赖性
—Manage model dependencies
'on'(default) |'离开'
什么时候托管依赖性
被设定为上
,如果需要,模型依赖项会自动发送到并行工人。如果托管依赖性
被设定为离开
,明确将模型依赖性附加到并行池。
UseFastRestart
—Use fast restart
'离开'(default) |'on'
什么时候UseFastRestart
被设定为上
,使用快速重新启动在工人上进行模拟。
什么时候performing a parameter sweep varying properties of a Simscape™ component (e.g. mass and inertia of a Solid block in Simscape Multibody), specify the Simscape block parameter as run-time configurable. For more information, seeAbout Simscape Run-Time Parameters(SIMSCAPE).
Note
使用时parsim
, use theUseFastRestart
选项,而不是FastRestart
option. SeeGet Started with Fast Restart了解更多信息。
TransferBaseWorkspaceVariables
—将变量转移到平行工人
'离开'(default) |'on'
什么时候TransferBaseWorkspaceVariables
被设定为上
, variables used in the model and everything defined in the base workspace are transferred to the parallel workers.
显示模仿者
—Starts the Simulation Manager app
'离开'(default) |'on'
什么时候“显示模仿者”
被设定为'on'
,您可以使用Simulation Manager应用程序监视仿真。
StopOnError
—Stop simulations on errors
'离开'(default) |'on'
环境'StopOnError'
to'on'
如果遇到错误,请停止执行模拟。
Output Arguments
SIMOut
— Simulation object containing logged simulation results
object
数组Simulink.SimulationOutput
objects that contains all of the logged simulation results. The size of the array is equal to the size of the array of万博1manbetxSimulink.SimulationInput
对象。
All simulation outputs (logged time, states, and signals) are returned in a singleSimulink.SimulationOutput
目的。您定义使用该模型时间,状态和输出数据导入/导出模型配置参数对话框的窗格。您可以使用块(例如到工作区和范围blocks. The信号和示波器经理可以直接记录信号。
Extended Capabilities
自动平行支持万博1manbetx
通过使用并行计算Toolbox™自动运行计算来加速代码。
如果安装了并行计算工具箱,则使用parsim
, MATLAB automatically opens a parallel pool of workers on your local machine. MATLAB runs the simulations across the available workers. Control parallel behavior with the parallel preferences, including scaling up to a cluster.
For details, see运行多个模拟.
Version History
matlab명령
다음matlab명령명령해당링크를했습니다했습니다。
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
选择一个网站
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:.
您还可以从以下列表中选择一个网站:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
美洲
- AméricaLatina(Español)
- 加拿大(英语)
- 美国(英语)