%Value = 100 * rand(1,2000);
Value = zeros(1,675);
Value = x;
Best_Value = zeros(1,675);
Forecast_Noise = 0.01;
Measure_Noise = 0.01;
Last_Best_Value = Value(1);
Best_Error = 0;
for i = 1 : 1 : 675
Forecast_Value = Last_Best_Value;
Measure_Value = Value(i);
Forecast_Error = sqrt(Forecast_Noise ^ 2 + Best_Error ^ 2);
Measure_Error = Measure_Noise;
Kalman_Gain = sqrt(Forecast_Error ^ 2 / (Forecast_Error ^ 2 + Measure_Error ^ 2));
Best_Value(i) = Forecast_Value + Kalman_Gain * (Measure_Value - Forecast_Value);
Best_Error = sqrt((1 - Kalman_Gain) * Forecast_Error ^ 2);
Last_Best_Value = Best_Value(i);
end
plot(Best_Value,'r');
hold on;
plot(Value)
【滤波】卡尔曼matlab仿真代码
最新推荐文章于 2021-03-31 09:51:38 发布