选择一个模拟模式
Simulation Mode Tradeoffs
In general, you must trade off simulation speed against flexibility when choosing either Accelerator mode or Rapid Accelerator mode instead of Normal mode.
Normal mode offers the greatest flexibility for making model adjustments and displaying results, but it runs the slowest.
Accelerator mode lies between Normal and Rapid Accelerator modes in performance and in interaction with your model. If your model has 3-D signals, use Normal or Accelerator mode. Accelerator mode does not support runtime diagnostics.
Rapid Accelerator mode runs the fastest, but this mode does not support the debugger or profiler, and works only with those models for which C code is available for all of the blocks in the model. In addition, Rapid Accelerator mode does not support 3-D parameters and sinks.
Note
An exception to this rule occurs when you run multiple simulations, each of which executes in less than one second in Normal mode. For example:
for i=1:100 sim(model); % executes in less than one second in Normal mode end
Tip
To gain additional flexibility, consider using model referencing to componentize your model. If the top-level model uses Normal mode, then you can simulate a referenced model in a different simulation mode than you use for other portions of a model. During the model development process, you can choose different simulation modes for different portions of a model. For details, seeSimulate Model Reference Hierarchies.
Comparing Modes
The following table compares the characteristics of Normal mode, Accelerator mode, and Rapid Accelerator mode.
If you want to... | Then use this mode... | ||
---|---|---|---|
Normal | Accelerator | Rapid Accelerator | |
Performance | |||
Run your model in a separate address space | ![]() |
||
Efficiently run batch and Monte Carlo simulations | ![]() |
||
Model Adjustment | |||
Change model parameters such as solver, stop time without rebuilding | ![]() |
![]() |
![]() |
Change block tunable parameters such as gain | ![]() |
![]() |
![]() |
For more information on configuration set parameters which can be modified without requiring rebuild, seeCode Regeneration in Accelerated Models | |||
Model Requirement | |||
Accelerate your model even if C code is not used for all blocks | ![]() |
||
Support Interpreted MATLAB Function blocks | ![]() |
![]() |
|
Support Non-Inlined MATLAB language or Fortran S-Functions | ![]() |
![]() |
|
Permit algebraic loops in your model | ![]() |
![]() |
|
Have your model work with the debugger or profiler | ![]() |
![]() |
|
Have your model include C++ code | ![]() |
![]() |
|
Data Display | |||
Use scopes and signal viewers | ![]() |
![]() |
SeeBehavior of Scopes and Viewers with Rapid Accelerator Mode |
Use scopes and signal viewers when running your model from the command line | ![]() |
![]() |
Note
Scopes and viewers do not update if you run your model from the command line in Rapid Accelerator mode.
Decision Tree
Use this decision tree to select between Normal, Accelerator, or Rapid Accelerator modes.
SeeComparing Performanceto understand how effective the accelerator modes will be in improving the performance of your model.