How do i implement moving average for prediction?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ali
el 24 de Feb. de 2019
Respondida: Krishna Zanwar
el 27 de Feb. de 2019
I implemented moving average in excel (data file attached).Also shown in attached image.
Now i want to apply my data in MATLAB for result analysis.
i tried "movmean" and "filter" function but results are different from excel file.I tried like this:
clc
clear all
data3=xlsread ('2.xlsx','C:C');
% check with movmean function
M = movmean(data3,2)
subplot (2,1,1)
plot (data3)
hold on
plot(M)
% check with filter function
N = 2;
MA = filter(ones(N,1),N,data3);
subplot (2,1,2)
plot (MA)
- I want to take moving average with interval 2.
- Predict the future values (for instance:if there are 180 rows i want to calculate step ahead prediction of row 181,182 using avergae of previous two values)
![Moving average_Forecasting.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/205581/Moving%20average_Forecasting.jpeg)
0 comentarios
Respuesta aceptada
Krishna Zanwar
el 27 de Feb. de 2019
Hey Ali,
It seems like in the Excel sheet the moving mean of ‘Actual’ is printed in ‘Forecast’.
In Matlab ‘Forecast’ is used as an input and so the output ‘M’ is not matching, in the same code if you take ‘Actual’ as input it will give you the same output as Excel.
data3=xlsread ('2.xlsx','B:B');
To get 181 and 182 outputs by averaging the previous two outputs you can do this-
M(end+1)=(M(end)+M(end-1))/2;
M(end+1)=(M(end)+M(end-1))/2;
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre AI for Signals en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!