Averaging fluctuating curves in a single one

4 views (last 30 days)
I have these curves as results from different cases.
I want to make an average curve around which these curves fluctuate to express the whole data in a single average curve. How?
  1 Comment
dpb
dpb on 16 Sep 2020
Use mean() over proper dimension depending on whether are stored by row or column...

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 16 Sep 2020
Assuming they all have values at the same set of x coordinates, just average them:
yMean = (y1+y2+y3+y4+y5+y6+y7+y8+y9) / 9;
or if they're row vectors:
yMean = mean([y1;y2;y3;y4;y5;y6;y7;y8;y9], 1);
If they're column vectors, use commas and 2:
yMean = mean([y1,y2,y3,y4,y5,y6,y7,y8,y9], 2);
If the curves have different x vectors, then you'll have to interpolate them using a common set of x values
x = unique([x1(:);x2(:);x3(:);x4(:);x5(:);x6(:);x7(:);x8(:);x9(:)]);
y1 = interp1(x1(:), y1(:), x(:)); % y1 will be a column vector.
That should work for both row vectors or column vectors. Repeat for the other data vectors.

More Answers (0)

Categories

Find more on Fit Postprocessing in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!