Algebraic Loop Caused by MATLAB Function Block. How to Resolve Without Time Delay?

7 ビュー (過去 30 日間)
Hello, I have a block diagram of a closed loop control system that uses a MATLAB Function Block to describe a plant model. In this function block I use MEX functions to acquire data from another software, so that I can generate outputs for the function block. I also use memory blocks to create persistent variables that are inputs and outputs from the function block. Because I am using some of the outputs as feedback in the control loop, it creates algebraic loops. To resolve this I was using delay blocks and memory blocks with initial conditions, but this shifts the signal by one time step which is undesirable.
My sim is a fixed time step of 1 second.
I tried to use the IC block as suggested from another post and a Mathworks page, but this doesn't resolve the algebraic loop for some reason. If I simply ignore the algebraic loop warnings, I get the desired response, but I am unsure if this has negative impacts on my simulation, such as step computation time, incorrect output values, etc.
  1 件のコメント
Paul
Paul 2023 年 1 月 6 日
Adding an IC block doesn't remove an algebraic loop. The IC block is intended to help the algebraic loop solver solve the algebraic loop.

サインインしてコメントする。

採用された回答

Fangjun Jiang
Fangjun Jiang 2023 年 1 月 6 日
If you suspect your MATLAB Function block or your MEX function caused the algebraic loop, consider setting this "Direct Feedthrough" flag false and try again.
This should only be done when it's realy hard to analyze where is the algebraic loop. Wether there is a direct feedthrough thus causing algebraic loop is a fact. It is not something that can be resolved by setting a flag. Inserting a delay is the only solution.
"If I simply ignore the algebraic loop warnings, I get the desired response, but I am unsure if this has negative impacts on my simulation, such as step computation time, incorrect output values, etc."
There shouldn't be any significant negative impacts. In fact, I think somewhere in the diagnostics you can set to not report this algebraic loop warning.
Simulink will automatically insert delays behind the scene to resolve the algebraic loop. If you get the desired response, then take it. You got different results when you add delays or memory blocks by yourself. It only means you added more delays or the delays are not added at the right place.
  7 件のコメント
Paul
Paul 2023 年 1 月 6 日
I wasn't trying to answer the OP's question, just commenting on other comments in the thread.
In summary, I think we are now in agreement on almost everything.
Simulink models can contain two types of algebraic loops: true and artificial.
Either type of algebaic loop can be removed. The speciific options for the user for doing so depend on the type of algebraic loop and the blocks contained in the loop.
If not removed, Simulink tries to solve either type of algebraic loop during execution using an iterative solver.
I think our only area of disagreement is if there are any circumstances under which Simulink will automatically add delay (or memory?) blocks to remove an algebraic loop. I've searched the 2021b doc and can't find anything about that. If you come across that in the future and remember this thread, I hope you'll come back here and provide more details, example, etc.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by