Cannot solve algebraic loop involving 'Mo_phong_​xe/Equatio​n1_ddgama1​/MATLAB Function5' because it consists of blocks that cannot be assigned algebraic variables, such as block

1 vue (au cours des 30 derniers jours)
Cannot solve algebraic loop involving 'Mo_phong_xe/Equation1_ddgama1/MATLAB Function5' because it consists of blocks that cannot be assigned algebraic variables, such as blocks with discrete-valued outputs, blocks with non-double or complex outputs, Stateflow blocks, or nonvirtual subsystems. Consider breaking the algebraic loop. For example, add a delay or a memory block to the loop. To see more details about the loops use the command Simulink.BlockDiagram.getAlgebraicLoops(bdroot)
Component:Simulink | Category:Model error
Input ports (23) of 'Mo_phong_xe/Equation1_ddgama1/MATLAB Function5' are involved in the loop.
  3 commentaires
Viet Dung
Viet Dung le 17 Juin 2024
Yes, I will send my simulink model in email. Hope you can solve it

Connectez-vous pour commenter.

Réponses (2)

R
R le 18 Juin 2024
Thanks for sharing the model. As prompted by the error message, there is an algebraic loop in the model. Refer to the following MATLAB Answer to understand about algebraic loop and how to solve them.
In this particular case, the algebraic loop occurs because the input signals ddgama1, dgama1 and gama1 are driven by the output of the same block. To resolve the algebraic loop error, you can add a Unit Delay block to the ddgama1 signal as suggested in the error message. Refer to the screenshot below:
Additionally, you may encounter similar algebraic loop error messages in other subsystems within the model. These errors can be resolved using the same method outlined above.

Sam Chak
Sam Chak le 18 Juin 2024
It looks like the root cause of the issue have been identified. Let me walk through the details:
The second-order differential equation was described incorrectly in the code. On the left-hand side (the output of the function), you have ddgama1 (). However, on the right-hand side (in the lengthy equation), ddgama1 is also one of the inputs to the function.
In other words, you can't calculate the output value ddgama1 without first feeding in the input value of ddgama1. This creates a circular reference, which results in a Algebrain Loop Error - a situation where a calculation depends on itself, either directly or indirectly.
Code in MATLAB Function block:
function ddgama1= fcn(I1, Ig, ddteta, Cg, dgama1, dteta, Kd, Zta, y, Kb, gama1, gama2, Cb, dgama2, neta1, M1, Rg, l, M2, M3, M4, M5, ddgama1, ddgama2, ddgama3, ddgama4, ddgama5)
ddgama1 = (Ig*ddteta - Cg*(dgama1 - dteta) - Kd*Zta^2*gama1 + Kd*Zta*y - Kb*(gama1 - gama2) ...
- Cb*(dgama1 - dgama2) + neta1*M1*(Rg*ddteta - neta1*ddgama1) ...
- l*(M2*(Rg*ddteta + l*ddgama1 + l/2*ddgama2) + M3*(Rg*ddteta + l*ddgama1 + l*ddgama2 ...
+ l/2*ddgama3) + M4*(Rg*ddteta + l*ddgama1 + l*ddgama2 + l*ddgama3 + l/2*ddgama4) ...
+ M5*(Rg*ddteta + l*ddgama1 + l*ddgama2 + l*ddgama3 + l*ddgama4 + l/2*ddgama5)))/I1;
end
Explanation:
When the highest-order derivatives appear on both sides of the equation, it implies that this is a coupled system of at least five differential equations: ddgama1, ddgama2, ddgama3, ddgama4, and ddgama5.
Mathematically, you'll need to decouple or resolve this system of five equations before implementing the code in the MATLAB Function block. I'd highly recommend solving the differential equations in MATLAB using ode45() and odeset(), as this will allow you to group all the highest-order derivatives on the left-hand side and specify the matrix as 'Mass'.
  1 commentaire
Sam Chak
Sam Chak le 18 Juin 2024
By the way, you could potentially avoid solving the issue by simply using the Unit Delay block, as @R had suggested. However, if such an approach were to be submitted for publication in a high-impact journal, the reviewers would likely question whether the system is being correctly simulated.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Matrix Computations dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by