What is the Memory Block actually useful for?

11 views (last 30 days)
In the Aerospace Blockset example :
Why are these Memory blocks used? How do they affect the simulation?

Accepted Answer

Paul on 18 Jan 2023
Hi Islam,
Memory blocks are often used to remove algebraic loops. The doc talks about this concept, just do a search. Here's a doc link that shows how to use unit delays, which are similar to memory blocks in this context, to remove algebraic loops.
My hypothesis is as follows:
In the model asbSkyHogg, if you trace the signal "alpha_dot,beta_dot" you will see that it is divided into alpha_dot and beta_dot in the PlantData bus, which goes to the Aerodynamics block. alpha_dot then gets pulled out of the bus and goes into the Datcom model to compute F and M. Typically, alpha_dot is only needed to compute M, not F. However, it looks like that block doesn't really allow for that division of labor. Anyway F and M come back around and if you trace F carefully (ignoring the memory blocks), you'll see that alpha_dot,beta_dot is a function of F. So without the memory blocks, alpha_dot is a function of F and Simuink thinks that F is a function of alpha_dot through that Datcom block. Hence, an algebraic loop. There really wouldn't be an algebraic loop if F and M were computed separately, Becuase the sequnce could then go as: compute F, compute alpha_dot, compute M.
Simulink can solve algebraic loops, but it can slow down simulation time. If a Memory block is required, as may be the case here because of how the Datcom block is implemented, the way this 2022a model is implemented is not good, to say the least. Without getting into my educated guess as to why the implementer did it that way, the net result is that the algebraic loop is removed, but at the expense of messing up ALL of the dynamic equations, with various quantities not obeying the fundamental dynamic and kinematic equations of motion. The degree to which this impacts the results is wholly dependent on the solver step size. Qualitatively, large steps more problematic than small steps.
A MUCH BETTER approach would have been to only put a memory block on the output of the calc_alpha_dot block or on the alpha_dot input to the Datcom block. Maybe this approach is done in the 2022b version that @Abhinav is looking at.
Summary: In this model the memory blocks are introduced to remove an algebraic loop. It could have been done mucy, much, much better.
Having said all that, my analysis is based only on looking at the model. I didn't actually try to run it or experiment with modifying it.
Islam Elnady
Islam Elnady on 26 Jan 2023
@Paul Thank you. I appreciate your help. I had already tried to implement a TF but often gets troubled setting the time constant value. It often either slows down the simulation or messes up the results. I do know it usually works well. But didn't work well in my case.
Btw, have you had a look at my other question in the link I referred to? I'd appreciate if it's relevant to your knowledge.

Sign in to comment.

More Answers (1)

Abhinav on 17 Jan 2023
The Memory block holds and delays its input by one major integration time step. When placed in an iterator subsystem, it holds and delays its input by one iteration. This block accepts continuous and discrete signals. The block accepts one input and generates one output. Each signal can be a scalar, vector, matrix, or N-D array. If the input is non-scalar, the block holds and delays all elements of the input by the same time step.
Refer to the following documentation to learn more about memory block :

Sign in to comment.


Find more on General Applications in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!