Averaging fluctuating curves in a single one
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Image Analyst
2020-9-16
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.
0 个评论
更多回答(0 个)
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!