How do I find the coordinate position of the highest point in the gap under all these curves?

1 回表示 (過去 30 日間)
I have the below figure with 64 individual curves plotted. There is a vertical threshold over which these curves need to be. The width of the space over this threshold is shown as the DoF and is positioned by those two vertical lines, which can be anywhere the most central parts of the curves intersect with the threshhold.
My question is how do I determine the highest point of the area between the vertical lines and above the threshold but below all the curves? This might not coincide with an intersection.
The curves do not have the same domain (meaning their X values are not aligned).
The only way I can think of, which is really clunky, is to loop through x values from left to right, interrogate each curve by interpolating a point at that x value, getting the minimum of all those values, and moving to the next x. That builds a list of minimum values, and then I choose the maximum value of those minimums.
Is there are more clever way to do this? Can I do this with the plotted data? It's almost like I want to build a shape and then find the maximum y value of that shape.
Thank you for any help!
  1 件のコメント
jonas
jonas 2018 年 7 月 25 日
編集済み: jonas 2018 年 7 月 25 日
Interesting, I can imagine a few ways to go about this. Can you provide a few representative curves to work with?
Is the threshold fixed or just a minimum?

サインインしてコメントする。

採用された回答

gwoo
gwoo 2018 年 7 月 26 日
編集済み: gwoo 2018 年 7 月 26 日
I took the numerical approach where I would recreate the individual curves within the same domain and using the same increments. This could be done with interpolation where:
newCurve = interp1(origXvalues, origYvalues, newXvalues)
But I have the polynomial coefficients of the curves I use so I just re-evaluated the polynomial over the bounded domain and used a very small increment:
% X domain of interest
minX;
maxX;
% Nx1 Cell array where rows are curve data (polynomial coefficients in this case)
cellArray;
% Pre-populate matrix where columns are curves
matCurves = [];
% Hi-res domain values
newDomain = linspace(minX, maxX, 10000)';
% Cycle through curve sets
for jj = 1:size(cellArray, 1)
% Generate curve based on polynomials bounded within domain
matCurves(:, jj) = polyval(cellArray{jj}, newDomain);
% Or to use interpolation if cellArray had X and Y values as columns
% matCurves(:, jj) = interp1(cellArray{jj, 1}, cellArray{jj, 2}, newDomain);
end
% Find global max of the min of each domain increment
[minValues, idx] = max(min(matCurves, [], 2));
% Path that traces the lowest values within the domain
minValues;
% X value of maximum point below all curves within domain
newDomain(idx);
This worked great for me and is really fast. Looping to generate the new curves with `polyval` or `interp1` is what takes the longest but in total for my data set of 68 curves and generating new curves with 10000 points, start to finish only took 0.06 seconds on my 7th-gen Core i7 laptop.
Also, thanks to @Fangjun Jiang in this thread, the answer at Answer 411357 - How to plot the highest y values for each x value for a figure with multiple plots. This is a great help and very clever. Exactly what I was looking for originally but didn't find it until after I came up with my numerical solution. Looking at it, it doesn't quite work with my data set, because it requires that the curves already be of the same X domain, which mine are not. Also my curves are in groups in graphics containers so it's a little harder to get access to them compared to how that answer does with just 2 Children calls.

その他の回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2018 年 7 月 25 日
I think it is similar to this question. Regarding "shaping the minimum" and then "finding the maximum" over the plotted data, you can reference the example in the answer.
  1 件のコメント
gwoo
gwoo 2018 年 7 月 26 日
Thanks for this link! Looks like what I was thinking originally before I ended up coming up with my own solution. I've referenced this link and you in my solution below. Thank you very much! I can see that answer you linked being useful in other places.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by