Average data points of different X,Y range

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

 Respuesta aceptada

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.
.

2 comentarios

ArBio
ArBio el 14 de Mzo. de 2024
Thank you @Star Strider for the help.
Star Strider
Star Strider el 15 de Mzo. de 2024
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 14 de Mzo. de 2024

Comentada:

el 15 de Mzo. de 2024

Community Treasure Hunt

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

Start Hunting!

Translated by