Find average of multiples lines

5 ビュー (過去 30 日間)
Vince Clementi
Vince Clementi 2018 年 2 月 1 日
コメント済み: Marcus Leiwe 2020 年 3 月 27 日
Hi All,
Having more trouble than I should finding the average line from 7 records. Each record is basically [T, (a-b)], where T is a common time interval (0:0.1:30) and (a-b) is the difference between two data sets (a-b, a-c, a-d, etc.).
I've designated each "difference" as such: diff, diff2, diff3, diff4, diff5, diff6, diff7. I am easily able to plot all of these records on the same plot. However, each method to find the mean of these lines fails. SO far, I have used mean([diff diff2, etc.],7). How do I go about finding the average for each common time point and then plot that?
Thanks.
  7 件のコメント
Vince Clementi
Vince Clementi 2018 年 2 月 1 日
Thanks! I'll give it a shot.
Bob Thompson
Bob Thompson 2018 年 2 月 1 日
Let me know if it works, and I can post as an official answer, or if you have some trouble shooting you can post your own answer.

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

採用された回答

Greg
Greg 2018 年 2 月 1 日
Regarding the follow-up question found in the comments (NaN affecting the mean):
Use the 'omitnan' flag of the mean function (R2015a and newer):
%%%I wouldn't use "diff" as a variable name - it's a function
avg = mean([diff1, diff2, diff3, diff4, diff5, diff6, diff7],2,'omitnan');
  2 件のコメント
Bob Thompson
Bob Thompson 2018 年 2 月 1 日
That's pretty good, definitely gets rid of having to do a manual check.
Marcus Leiwe
Marcus Leiwe 2020 年 3 月 27 日
I think there is a function called nanmean that will do the same too

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by