GUI graph marker that moves with a slider

조회 수: 3 (최근 30일)
Tyler Martin
Tyler Martin 2017년 4월 19일
답변: Chaitral Date 2017년 4월 24일
Hello guys,
I am a complete Matlab novice and need some help. I am trying to create a GUI with push buttons reading an excel file and plotting a graph to the axes. I also need two sliders to control a marker that traces the graph. How can I set the sliders to read from the graph and trace it with a line?
  댓글 수: 1
Jan
Jan 2017년 4월 19일
The question is not clear. What does "tracing a graph" mean? What is "read from the graph and trace it with a line"?

댓글을 달려면 로그인하십시오.

채택된 답변

Chaitral Date
Chaitral Date 2017년 4월 24일
Please refer to the sample code given below. It will give you an idea about how you can control the position of the marker using sliders.
fig=plot(1:10)
txt = uicontrol('Style','text',... 'Position',[400 45 120 20]); L1=line(1,1,'Marker','*'); SL1=uicontrol('Style','slider','Min',1,'Max',4,'Value',3,'Position', [400 20 120 20],... 'Callback',@(obj,~)updatestring(obj,txt,L1));
function updatestring(obj,txt,L1) txt.String=obj.Value; L1.XData=obj.Value; L1.YData=obj.Value; end
I hope this helps.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-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