フィルターのクリア

For loop evaluation in Jacobian Solver

2 ビュー (過去 30 日間)
Andrew
Andrew 2024 年 1 月 16 日
回答済み: Shubh 2024 年 1 月 19 日
I have a simulink model where the state derivatives are in a feedback loop with a for iterator subsystem. As a result, in order to calculate an accurate Jacobian, I need the for iterator (or while iterator) to execute every time a relevant variable is perturbed, and currently it only evaluates once per time step. Is this functionality possible in vanilla simulink, or do I need stateflow in order to execute this function properly.
-Andrew

回答 (1 件)

Shubh
Shubh 2024 年 1 月 19 日
Hi Andrew,
In Simulink, the behavior of the For Iterator or While Iterator subsystems is primarily governed by the simulation settings and the configuration of the blocks within these subsystems. By default, these iterator subsystems execute once per simulation time step. However, there are a few approaches you can consider to achieve the behavior you're describing, where the subsystem needs to re-evaluate every time a relevant variable is perturbed within a time step.
  1. Subsystems with Enabled Ports: You can use an Enabled Subsystem where the enable signal is driven by the change in your relevant variable. This can potentially cause the subsystem to execute multiple times within a single time step if the enable signal changes. However, this approach depends heavily on how your variables change and how the enable signal is generated.
  2. Rate Transition Blocks: If the changing variable is sampled at a higher rate than the rest of your model, you can use Rate Transition blocks to manage the data transfer. This might not exactly execute the subsystem multiple times per time step, but it can help in managing data at different rates.
  3. Using Function-Call Subsystems: This approach is a bit more advanced. You can use function-call subsystems that are triggered by a function call event. This can potentially allow the subsystem to re-execute whenever the function call is triggered within a time step. This would require generating function call events based on the changes in your variables.
  4. Solver Configuration: Adjusting the solver settings, like decreasing the step size or using a variable-step solver, can increase the frequency of the evaluations. This doesn’t directly cause multiple evaluations per time step but can make the solver more responsive to changes in the system dynamics.
  5. Custom S-Function: Writing a custom S-Function block allows for more control over execution during a simulation step. You can program the S-Function to re-evaluate based on changes in certain variables. This, however, requires a good understanding of MATLAB S-Function API and how Simulink works internally.
  6. Stateflow for Event-Driven Logic: If none of the above solutions work, using Stateflow might be a viable option. Stateflow excels in designing event-driven systems where states and actions can change dynamically within a time step. However, integrating Stateflow with the existing Simulink model might require some restructuring of your model logic.
In summary, while vanilla Simulink might offer some solutions, they often require careful design and may not directly offer the straightforward functionality of re-evaluating a subsystem multiple times within a single time step based on variable changes. Stateflow offers more flexibility for event-driven dynamics, but it requires transitioning part of your logic to a Stateflow chart. Each method has its trade-offs, and the choice largely depends on the specific requirements and constraints of your model.
Hope this helps!

カテゴリ

Help Center および File ExchangeSimulink Functions についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by