Borrar filtros
Borrar filtros

Calculating cross-point within a set of x & y data

7 visualizaciones (últimos 30 días)
Sonoma Rich
Sonoma Rich el 20 de Jul. de 2011
I have a set of x & y data that I collected from a test. The plot of the data resembles a mountain with a single peak. Given this set of data, I want to calculate the values for x where y is 98% of the peak (max) value. There are two values for x. Any suggestions.
x =
-0.0004
0.0521
0.1047
0.1573
0.2100
0.2630
0.3152
0.3687
0.4200
0.4753
0.5261
0.5791
0.6313
0.6830
0.7365
0.7896
0.8431
0.8943
0.9474
1.0004
y =
17.9863
18.7457
19.6454
20.7195
21.8660
23.0983
24.7895
26.6830
29.0743
31.8048
35.1163
39.2968
44.3394
51.4311
58.5378
51.3318
42.9399
37.2848
33.2080
30.2815

Respuesta aceptada

Sean de Wolski
Sean de Wolski el 20 de Jul. de 2011
[mxy idx] = max(y); %max and index
y98 = 0.98*mxy; %value of y crossing
pt1 = interp1(y(1:idx),x(1:idx),y98); %interp lower value
pt2 = interp1(y(idx:end),x(idx:end),y98); %interp higher value
plot(x,y,'b-',[pt1 pt2],[y98 y98],'gd') %visualize
Edit for multiple x-ings Per comments:
x = cumsum(repmat(x,3,1)); %sample data your x/y from before
y = repmat(y,3,1);
y98 = 0.98*max(y);
yxing = y-y98; %zero the yvalue
ylox = find(diff(sign(yxing))); %crossings
ylox(:,2) = ylox+1; %both sides
ylox = ylox(:);
xvals = reshape(x(ylox),[],2); %set up poits
yvals = reshape(y(ylox),[],2);
n = size(xvals,1);
xings = zeros(n,1);
for ii = 1:n
xings(ii) = interp1(yvals(ii,:),xvals(ii,:),y98); %interp each point
end
plot(x,y,'b-',xings,y98,'gd') %visualzie
  1 comentario
Sonoma Rich
Sonoma Rich el 20 de Jul. de 2011
This will work for this data set, but what if the data set had two or three humps (peaks) with multiple cross-points? Any suggestions?

Iniciar sesión para comentar.

Más respuestas (1)

Oleg Komarov
Oleg Komarov el 20 de Jul. de 2011

Categorías

Más información sobre Industrial Statistics en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by