Why moving average plot is not starting as the original signal
3 ビュー (過去 30 日間)
古いコメントを表示
Hi, I am trying to analyze a stock data with only two columns i.e dates and value of stocks Both of these columns have length=63.I am trying to calculate the moving average to smooth the curve.I use the following code and get the out put as shown below
window=5;
mask=ones(1,window)/window;
quarter=conv(stocks,mask,'same');
plot(dates,stocks)
hold on
plot(dates,quarter)
ylim([7300,7700])
legend('input data' ,'filtered data')
Why the filtered data curve is not starting from the point where the original input data is starting? How to fix the plot? Is my method to get the moving average right? Is there a better way? thanks
0 件のコメント
回答 (1 件)
Walter Roberson
2018 年 4 月 4 日
You are getting effects from the zero padding. See the 'valid' option instead of 'same'
Or consider using
quarter = movavg(stocks(:), 'simple', window) .';
参考
カテゴリ
Help Center および File Exchange で Multirate Signal Processing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!