Clear Filters
Clear Filters

problem with trained model/unit delay

4 views (last 30 days)
M.M
M.M on 3 Jun 2022
Answered: Yash on 10 Jan 2024
Hello,
I trained three models using the regression learner MATLAB app and then exported the trained functions to Simulink. When I run the Simulink model below, I get the following error:
error:
"Cannot solve algebraic loop 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"
When I add unit delays as shown below, there is no error, but the trained models can not predict the desired response (while my model is validated by 90%). The unit delay appears to be the cause, as it alters the system from continues to a discrete and feeds the incorrect output as an input.
The red figure in the following picture represents the Simulink-trained model, while the blue one represents the desired output. As you can see, the red figure follows the blue one for around 0.5 seconds, but then it is weird!
I'd like to ask you about the issue I'm having with unit delay:
-Is there another technique to solve an algebraic loop?
Thank you in advance for your help
  3 Comments
M.M
M.M on 6 Jun 2022
Thank you for responding.
I tried the Memory block, but got the same result as before.
Alex Alex
Alex Alex on 6 Jun 2022
Try....treat as atomic unit in Block Parameters for MATLAB Function....no idea for more

Sign in to comment.

Answers (1)

Yash
Yash on 10 Jan 2024
Hi,
Algebraic loops in Simulink occur when an output of a block or a set of blocks is required to compute its own input without any delay, which can lead to computational issues since Simulink needs to determine the values simultaneously. Breaking an algebraic loop often involves introducing some form of delay or memory to provide a dependent relationship between inputs and outputs. You mentioned that you tried using a Unit Delay block, but it alters the system from continues to a discrete and feeds the incorrect output as an input.
To solve this, you can use Transport Delay block, which can introduce a continuous delay to the signal without discretizing it. The Transport Delay block does not interpolate discrete signals. Instead, the block returns the discrete value at the required time. This block differs from the Unit Delay block, which delays and holds the output on sample hits only.
To know about the Transport Delay block, refer to its documentation here: https://in.mathworks.com/help/simulink/slref/transportdelay.html
Hope this helps

Community Treasure Hunt

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

Start Hunting!