Simulink algebraic loop makes unexpected behaviour
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?
0 commentaires
Réponses (1)
ag
le 1 Mai 2025
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!
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!