Simulink algebraic loop makes unexpected behaviour

6 ビュー (過去 30 日間)
abbas jafarpour
abbas jafarpour 2022 年 3 月 12 日
回答済み: ag 2025 年 5 月 1 日
Hello, i have the following simple algebraic loop:
The function inside the fcn is as follows: Code Logic: whenever the input #2 equals to 0, console diplays "AAAA" and whenever the input #2 equals to 33, the console displays "XXXXXXX";
function y = fcn(u)
y = [0 0];
if(u(2) == 0)
disp("AAAA")
end
if(u(2) == 33)
disp("XXXXXXX")
end
y(1) = 33;
end
Because of the Initial condition, i expect the console to display "AAAA" only once and for the rest of the simulation the console will display "XXXXXXX". But to my amazement Console displays "AAA" Five times!
I cant understand why this happens. but the matter gets more complicated when i disable the lowest link (Updated image below)
As we can see with removing the idle link, every thing works fine!
The matter sure does relate to how simulink works with algebraic loops but i cant understand why this happens!
Can any one please help me understand why this happens?

回答 (1 件)

ag
ag 2025 年 5 月 1 日
Hi Abbas,
Algebraic loops occur when an input port with direct feedthrough is driven by the output of the same block, either directly, or by a feedback path through other blocks which have direct feedthrough. In your case, the cause seems to be the loop created by the feedback from MATLAB function block "fcn" to the block "ic3".
In most of the cases the solution is to model the system so that the loop is no longer present. In some cases, adding a small delay (Either discrete delay block or continuous memory block) to the system at its highest level might remove the loop.
For a better understanding of Algebraic loops and how can they be solved, I kindly suggest you to go through the following MATLAB answers post: https://www.mathworks.com/matlabcentral/answers/95310-what-are-algebraic-loops-in-simulink-and-how-do-i-solve-them
Hope this helps!

カテゴリ

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

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by