how to record and use the history of a variable in simulink
Show older comments
I am using Simulink for my project. My project is working in discrete time system. The task required to use more than one previous values of a variable to calculate the next step. Moreover, I want to vary the number of previous values for calculation. How can I do that ?
for example, at time = 100, i have 1~100; at time = 101, i have 2~101; at time = 102, i have 3~102 ; ...
Thanks you very much for help :)
Answers (1)
Fangjun Jiang
on 4 Jan 2012
0 votes
I don't know if you can change the number of previous steps dynamically. If the number is not large, you can always record the maximum number of previous steps. For example, use five Unit Delay blocks to record the the value of five previous steps. Then, in your calculation, you can decide whether you want to all five of them, or just three previous steps. You can set the coefficient of the 4th and 5th to be zero to achieve that effect.
6 Comments
Man Ho
on 5 Jan 2012
Fangjun Jiang
on 5 Jan 2012
Then try the Buffer block?
Man Ho
on 5 Jan 2012
Fangjun Jiang
on 5 Jan 2012
What do you mean by "but I want the values that is stored in the block, instead of the output value."? To me, the Buffer block accepts one input and gives 100 ouputs which are the previous values. It meets your need. What else are you looking for?
Man Ho
on 5 Jan 2012
Fangjun Jiang
on 6 Jan 2012
I see. Then I hope this "Delay Line" block is what you need.
http://www.mathworks.com/help/toolbox/dsp/ref/delayline.html
Categories
Find more on Sources 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!