How to predict step ahead/future values by applying moving average?

3 views (last 30 days)
I have used moving average for prediction as code is shown below.Now based on window/period i want to predict values for future.
For instance if there are total 180 rows in excel sheet i want to predict next /future rows with window or time interval of 7.I have done this in excel as shown in figure but i want to implement same in MATLAB.
clc
clear all
data=xlsread ('2.xlsx','C:C');
% A = [4 8 6 -1 -2 -3 -1 3 4 5];
% M = movmean(data3,2)
%%
period=7;
out = filter(ones(1,period),period,data);
%Now i want to predict step ahead as per values of period

Answers (1)

Harshit Jain
Harshit Jain on 5 Mar 2019
My assumption is that you want to predict values of future rows for which data is not there.
By carefully looking at excel prediction which you have attached above, you can see that excel just takes window of size = window_length - total_values_not_present and takes moving average of that for predicting future values. For e.g., If you add last six values and divide by 6 you'll get 228.0098, taking last 5 values and dividing by 5 gives you 247.00222, and so on.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!