Average running speed from time and speed trace

2 ビュー (過去 30 日間)
Victor Lejona
Victor Lejona 2015 年 11 月 2 日
回答済み: Star Strider 2015 年 11 月 2 日
I have a speed and time trace from which I'd like to calculate the average running speed, i.e. the average speed taking into account only the non-zero speed values.
Any ideas? Many thanks in advance.

回答 (1 件)

Star Strider
Star Strider 2015 年 11 月 2 日
I’m not certain how you want to calculate average speed, but this is one approach that uses only the non-zero speeds:
time = 0:0.1:10; % Create Data
speed = randi([0 9], 1, length(time)); % Create Data
nz_idx = speed>0; % Logical Vector Of Non-Zero Speeds
avg_speed = cumsum(speed(nz_idx)) ./ time(nz_idx); % Average Speed Of Non-Zero Speeds

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by