Writing a code for taking averaging at a point

3 ビュー (過去 30 日間)
Mayowa
Mayowa 2014 年 11 月 5 日
回答済み: per isakson 2014 年 11 月 6 日
I have vector of 100x1. Say 1-100. I want to take average at a particular point say 40. I want the average to be done in such a way that it will take 20 values on top and below 40 and add 40 itself making a total of 41 of sample. How can I write a code for this on matlab?

回答 (1 件)

per isakson
per isakson 2014 年 11 月 6 日
Run
vec = transpose(1:100);
ix = 40;
rng = 20;
avg = mean( vec( ix-rng : ix+rng ) );
and
>> avg
avg =
40

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by