Average data points of different X,Y range

4 views (last 30 days)
Dear all,
What is the correct technique to average curves of diferent X,Y ranges as shown by loosely dashed curves in the figure below? The solid blue curve, plotted by manual averaging of the parameters that fits the dashed curves does not seem to be representative.
Many thanks in advance.
AB

Accepted Answer

Star Strider
Star Strider on 14 Mar 2024
You have too interpolate all the curves to a single common independent variable. Then you can average them.
x1 = sort(rand(1,20))*20;
y1 = x1.^(1+rand);
x2 = sort(rand(1,15))*25;
y2 = x2.^(1+rand);
x3 = sort(rand(1,25))*30;
y3 = x3.^(1+rand);
xq = linspace(min([x1 x2 x3]), max([x1 x2 x3]), max([x1 x2 x3]));
y1i = interp1(x1, y1, xq);
y2i = interp1(x2, y2, xq);
y3i = interp1(x3, y3, xq);
ymean = mean([y1i; y2i; y3i], 'omitmissing');
Lv = xq <= min([max(x1) max(x2) max(x3)]);
figure
plot(x1, y1, '.')
hold on
plot(x2, y2, '.')
plot(x3, y3, '.')
plot(xq(Lv), ymean(Lv), '-g', 'LineWidth',2)
hold off
grid
The mean value does not exist beyond the length of th shortest vector. This approach accounts for that.
.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!