Simulink - Rapid Accelerator with varying inputs
1 次查看(过去 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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/602140/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/602145/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/602150/image.png)
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Manual Performance Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!