Simulink - Rapid Accelerator with varying inputs

7 ビュー (過去 30 日間)
TeichEnterich95
TeichEnterich95 2021 年 4 月 30 日
Hello,
I am running my Simulink model 'MyModel' -times in a script (let's call it 'MyScript.m') as it can be seen below. The goal is to build the model in rapid accelerator mode outside of the for-loops and then run the model -times with varying inputs. My Simulink 'MyModel' has 5 root level inputs with a fixed sampling time. The signals 'signal1' - 'signal5' are double workspace variables.
When running the script, I get the following:
Building the rapid accelerator target for model: MyModel
Successfully built the rapid accelerator target for model: MyModel
Error using MyScript (line 25) [Error occurs in the line with the 'sim' command]
In 'Simulink:Logging:UTInvDim', parameter {1} must be a real scalar.
I know that it is probably difficult to solve this problem without having access to the Simulink model. However, maybe someone can tell me if this the right way to run a Simulink model in rapid accelerator mode with varying inputs in general.
model = 'MyModel';
% Build rapid accelerator target
rtp = Simulink.BlockDiagram.buildRapidAcceleratorTarget(model);
% Create simulation object
sim_object = Simulink.SimulationInput(model);
% Set model parameters
sim_object = sim_object.setModelParameter('SimulationMode','rapid','StartTime','0','ReturnWorkspaceOutputs','on');
for i = 1:N
for ii = 1:M
% Set stop time
sim_object = sim_object.setModelParameter('StopTime','1');
% Set input signals of 'MyModel'
sim_object = sim_object.setExternalInput(signal1);
sim_object = sim_object.setExternalInput(signal2);
sim_object = sim_object.setExternalInput(signal3);
sim_object = sim_object.setExternalInput(signal4);
sim_object = sim_object.setExternalInput(signal5);
% Start simulation
sim(sim_object)
end
end

回答 (0 件)

カテゴリ

Help Center および File ExchangeManual Performance Optimization についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by