How to eliminate "undercuts" of a 2d curve?

1 回表示 (過去 30 日間)
paul harder
paul harder 2021 年 12 月 6 日
コメント済み: Star Strider 2021 年 12 月 9 日
I have a curve made up of a 2d vector of points which has "undercuts". I'd like to create a new curve which eliminates these undercuts. In the figure below, I want to turn the blue curve into the red curve. I could figure out something from scratch (maybe just march along x and skip indices where x does not increase,) but I suspect this can be done with existing functions. In the end, I'd also like to end up with an even point spacing in x, but I can handle that with interp1 after the fact if needed. thanks
  1 件のコメント
John D'Errico
John D'Errico 2021 年 12 月 6 日
I don't know of any simple solution, using existing tools. You will need to just write it. To the extent that this will use existing low level tools, you can describe that anyway you want. But no off the shelf tool exists that I can think of.

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

採用された回答

William Rose
William Rose 2021 年 12 月 7 日
編集済み: William Rose 2021 年 12 月 7 日
data=load('undercutdata.txt');
xin=data(:,1);
yin=data(:,2);
xout(1)=xin(1);
yout(1)=yin(1);
i=2; j=1;
while i<=length(data)
if xin(i)>xout(j)
xout(j+1)=xin(i);
yout(j+1)=yin(i);
i=i+1;
j=j+1;
else
i=i+1;
end
end
plot(xin,yin,'-b.',xout,yout,'-rx');
Produces the plot below.
The undercutting in the plot above is a bit different than in your drawing. To get results as in your drawing, modify as follows: change the code so it only removes undercuts where y is decreasing, on the first pass. Then negate the output y-vector, to turn the output of pass 1 upside down, and run it through the filter again. Then negate the output y-vector of pass 2, to turn it right-side up. Flippng it in time is an alterative to negation, and would give the same result.
  10 件のコメント
Star Strider
Star Strider 2021 年 12 月 9 日
The scapula application would be important in quantifying certain shoulder-girdle muscular dystrophies. (Not my area of expertise, however I remember them from my Neurology rotations.)
William Rose
William Rose 2021 年 12 月 9 日
@Star Strider, you are certainly correct. We collaborated with physicians at Nemours Children's Hospital and Shriners Childrens Hospital in Philadelphia. Subjects included patients with brachial plexus birth injuries and scoliosis.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCurve Fitting Toolbox についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by