I am calling a function in a different m file. I want this function to write newValues into an array. After 7 entries, the newValues need to be added to the end of the array and then shifted left in order to keep the values in order. Example: values accepted in the array are [1 2 3 4 5 6 7]. The new value is 8 which makes the array have values [2 3 4 5 6 7 8]. This is what I have so far….
function arrayWithLatestValues = fn_updateArray(newValue)persistent A;A = [A(2:end) newValue];arrayWithLatestValues = A; end
this is my output im getting:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Best Answer