フィルターのクリア

Highlight a data point on graph using slider

11 ビュー (過去 30 日間)
Anon
Anon 2021 年 1 月 15 日
コメント済み: Anon 2021 年 1 月 16 日
Hello,
I am making an app which plots a graph- i want to include a slider at the bottom of the graph so that when the user drags the slider, it shows the x,y coordinates for the corresponding data points
i have set the limits of the slider to go from 0 to the maximum x value
how could i use the app.Slider.Valuechangingfcn to get a smooth data highlighting?
Thank you

採用された回答

Cris LaPierre
Cris LaPierre 2021 年 1 月 15 日
My recommendation would be to create you highlight at the intial value of the slider at the same time you plot. Be sure to capture the plot object in a variable.
app.hghlt = plot(app.x(app.x==app.Slider.Value),app.y(app.x==app.Slider.Value));
The in your callback function, just update the XData and YData properties of the object. This is untested. It assumes your slider values can only be values in your x vector, that your x values are strictly increasing or decreasing, and that there are no duplicate values.
app.hghlt.XData = app.x(app.x==app.Slider.Value);
app.hghlt.YData = app.y(app.x==app.Slider.Value);
  21 件のコメント
Anon
Anon 2021 年 1 月 16 日
wonderful, thank you :) this is exactly what i needed
Anon
Anon 2021 年 1 月 16 日
thank you again for taking the time to do this i really appreciate it

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by