How to calculate mean to an equal area in Matlab?

4 ビュー (過去 30 日間)
Xuefei Sun
Xuefei Sun 2021 年 2 月 22 日
コメント済み: Xuefei Sun 2021 年 2 月 22 日
I have 900000 time data and 900000 speed data. I need to calculate the mean speed for each 30secs and plot them. How can I get that? Thank you!
  2 件のコメント
James Tursa
James Tursa 2021 年 2 月 22 日
Running average, or average of blocks? Is the time data equally spaced?
Xuefei Sun
Xuefei Sun 2021 年 2 月 22 日
Yes, the time data is equally spaced from 1 sec to 900000 sec. And I should calculate mean speed for each 3 sec. Like from 1 to 3, 4 to 6, 7 to 9, ect. And plot them

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

採用された回答

James Tursa
James Tursa 2021 年 2 月 22 日
編集済み: James Tursa 2021 年 2 月 22 日
n = 3; % or whatever number of samples you need, must be divisible into size of data
time_average = mean(reshape(time_data,n,[]));
speed_average = mean(reshape(speed_data,n,[]));
plot(time_average,speed_average)
  3 件のコメント
Xuefei Sun
Xuefei Sun 2021 年 2 月 22 日
But I still have another problem. If I block the time, it seems like the mean speed responding to a certain time(the mean time). But I want to plot the speed sustained in that 3 sec. I mean I want to plot a stragnt line in each 3 sec. Could you teach me how to do that?
Xuefei Sun
Xuefei Sun 2021 年 2 月 22 日
I delete mean for the time_average, and I got it then. Thank you so much.
time_average = reshape(time_data,n,[]);
speed_average = mean(reshape(speed_data,n,[]));
plot(time_average,speed_average)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by