I would like to store the output of a block (real number - e.g. 2.8), to a vector. The vector has a size 6x1. The 1st output should be recorded at position 1, the 2nd output to position 2 and etc. The 7th, however, should be recorded to position 1, the 8th to position 2 and etc.
Asked
Active
Viewed 987 times
0
-
So you only store the most recent 6 values? – Wolfie Sep 11 '17 at 13:31
-
Yes, this is correct – Trenera Sep 11 '17 at 13:32
-
What loop do you mean? Are you using [MATLAB Function Block](https://www.mathworks.com/help/simulink/slref/matlabfunction.html)? or is there some combination of blocks making a loop in your simulink model? – Sardar Usama Sep 11 '17 at 13:34
-
@Wolfie so a circular buffer of size 6...? Sounds like `pos = mod(ind-1,6)+1`. – Dev-iL Sep 11 '17 at 13:35
-
@SardarUsama - It's a Matlab Function Block nested within a SubSystem block. I need to take the output from the SubSystem block – Trenera Sep 11 '17 at 13:37
-
Possible duplicate of [Circular buffer in MATLAB, \*\*without\*\* copying old data](https://stackoverflow.com/questions/20890128/circular-buffer-in-matlab-without-copying-old-data) – m7913d Sep 11 '17 at 13:41
-
I'm not sure this is a duplicate if the OP wants to achieve this *in Simulink*? i.e. without writing a MATLAB function block... – Wolfie Sep 11 '17 at 13:43
-
@Wolfie - Thanks for the comment. I would assume that there could be a block that I connect to the input and set my buffer size to 6 – Trenera Sep 11 '17 at 13:44
-
That looks like it: https://ch.mathworks.com/help/dsp/ref/buffer.html – Trenera Sep 11 '17 at 13:47
1 Answers
1
-
3If you want to leave this as an answer, please flesh it out at least with a screenshot of a minimal demo model. This will help future readers. – Wolfie Sep 11 '17 at 14:03