MATLAB: Does editing one Kalman filter object change multiple

matlab coder

I create a structure, where one element is a Kalman filter object, then use repmat to create a larger structure containing multiple duplicates of the original structure. I then go through and individually change each index of the structure, but when I change the Kalman filter object state for one index, it is changing it for every index of the structure.

Best Answer

All indices seem to be pointing to the same location in memory for the Kalman filter object. Thus, updating one index of the structure changes the filter object that all indices are pointing to. This results in all the values changing. Separate Kalman filters need to be created for each index, so they will not overwrite each other.
Related Question