Average of selected elements in Matlab

1 回表示 (過去 30 日間)
Hoai An Nguyen
Hoai An Nguyen 2020 年 12 月 24 日
コメント済み: weikang zhao 2020 年 12 月 24 日
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 日
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 日
It has a problem... :(
weikang zhao
weikang zhao 2020 年 12 月 24 日
opps, 'x' is a column vector
a(:,3)=[nan,nan,nan,x(3:11).'].';

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by