Getting handles of lines and deleting last 2 line plots
7 ビュー (過去 30 日間)
古いコメントを表示
Hello. I am plotting some raw data from a spectrometer onto a UIAxes and a smoothed version of this data. So for each data curve, there are 2 plots.
I often have about 10 plots of raw data (and obviously 10 smoothed plots).
I want to be able to remove the last raw data (and its smoothed plot) and have tried the code below.
However, it doesn't seem to be doing what I want it to. When I first run this (from a pushbutton callback), it only removes one line and not 2.
I can't see my error.
try
h = findobj(app.UIAxes,'Type','line')
delete(h(2)); %Delete 2nd last line object
delete(h(1)); %Delete last line object
catch
end
0 件のコメント
採用された回答
Steven Lord
2020 年 2 月 14 日
I wouldn't assume that the first two elements of the array returned by findobj were the last two lines created. I don't think the documentation for findobj promises that behavior. Instead I would create the lines with specific Tag property values that reflect the order or that you store the lines in order in an array that you store in a property of your app, so you can "push" and "pop" them off in order in your line deletion method.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!