Averaging fluctuating curves in a single one

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

Use mean() over proper dimension depending on whether are stored by row or column...

Sign in to comment.

 Accepted Answer

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)

Products

Community Treasure Hunt

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

Start Hunting!