I was wondering if there is a way to eliminate the algebraic loop in Simulink model without using memory or delay blocks. These blocks tend to add slight overheads in the generated code associated with the creation and use of "state" variables.
Thank you very much for your help...and my apology for not able to elaborate more on the issue.
I hope the following example could help:
** The code and blocks shown below are modified because the original information are under non-disclosure**
I was trying to generate code for a moving average function. The function runs a counter and checks the counter result to determine actions: if the counter is still running, the function accumulates the input and store the result in "inputSum"; if the counter runs down to zero (indicated in the code by a flag "learnDone"), the function calculate out the moving average of the input based on "inputSum". I have to insert a delay block for the "learnDone" flag because its value depends on the counter result which is updated some steps later.
The code is fine except for the overhead marked in the picture below. If I am hand-writing the code, I could have got rid of either 'learnDone' or 'movingAvgDone' flag because they are redundant to each other.
I have learned that inserting delay block is a standard way in Simulink to avoid algebraic loop and data dependency error. However, this kind of overhead associated with delay block really gets me. I was wondering if there is anything I could do in Simulink to avoid it?
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
0 Comments
Sign in to comment.