How to apply moving harmonic average on an array?
3 ビュー (過去 30 日間)
I have attached the data Kd_i = (115*1), I want to keep first and last values as it is in the data (or also shown in the figure below) and in the row want compute the harmonic average of first and second values (red square), in the 3rd row I want to compute the harmonic average of second and thrid values (green square) asn so on...
I mean first and last values remain same (just to have final array/vector of equal length), and then from second row it moves the by computing the harmonic mean of first and second row, until second last row. Can someone help me to write it code?
Abhishek Tiwari 2022 年 7 月 3 日
A 'For' loop and harmmean() may do the same thing, as shown.
n = numel(Kd_i);
harmonicMean = Kd_i;
for idx = 2:n-1
harmonicMean(idx) = harmmean(Kd_i(idx-1 : idx, 1));