How do I interpolate values within a while loop?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Cai Chin
am 6 Dez. 2020
Beantwortet: Mohith Kulkarni
am 9 Dez. 2020
Hi, I am using MATLAB R2020a on a MacOS. I am trying to remove outliers in real-time from a vector called 'cycle_periods' in a while loop by comparing each value to the exponentially weighted moving mean of the previously 'accepted' values. If the value in this vector meets 2 conditions, it is added to a new vector 'accepted_cycle_periods' and the exponentially weighted moving average is updated to include the newly accepted vector value. If the condition is not met, a zero is instead added to 'accepted_cycle_periods' as a place holder and the weighted moving mean is not updated. Is there any way of removing these zeros in real-time as soon as a new vector value from 'cycle_periods' is accepted, and then replacing the zeros by values based on a linear interpolation of the newly accepted value and the previously accepted value in 'accepted_cycle_periods'?
Any suggestions would be much appreciated. Thanks in advance.
0 Kommentare
Akzeptierte Antwort
Mohith Kulkarni
am 9 Dez. 2020
You can use the interp1 function to interpolate the vector in the iteration when a new non zero value is added to the vector. You can refer the accepted answer for this question in the below link for details to interpolate a vector.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!