I have a data file, first column is Month, second column is Demand. I want to calculate the Moving Average of month 4 (=(month 1+2+3)/3) and so on. Then, I want to display the results in the 3rd column. How can I do?
Instead of using Excel, I want to use Matlab to calculate this. Please help me :(((

 채택된 답변

weikang zhao
weikang zhao 2020년 12월 24일
편집: weikang zhao 2020년 12월 24일

1 개 추천

easy, use "conv"
x=conv(a(:,2),[1/3,1/3,1/3]);
the first element and the second element of 'x' are useless.
have fun

댓글 수: 4

Hoai An Nguyen
Hoai An Nguyen 2020년 12월 24일
Thank you so much <3 But how can I display 3 column?
(So sorry if my English is not good to explain what I need :<<)
Add a line of code
a(:,3)=[nan,nan,nan,x(3:11)].';
Hoai An Nguyen
Hoai An Nguyen 2020년 12월 24일
It has a problem... :(
opps, 'x' is a column vector
a(:,3)=[nan,nan,nan,x(3:11).'].';

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

질문:

2020년 12월 24일

댓글:

2020년 12월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by