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

 채택된 답변

Star Strider
Star Strider 2024년 3월 14일
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

ArBio
ArBio 2024년 3월 14일
Thank you @Star Strider for the help.
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

질문:

2024년 3월 14일

댓글:

2024년 3월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by