Why slider is not working in my GUI?

25 次查看(过去 30 天)
I have created a GUI consisted of 4 axes, a push button and a slider. Although, the slider commands (callbacks, uicontrols, guidata etc) including the mouseScroll function, are perfectly working, because they have been tested to a different figure (not my GUI) consisted of a single hFig and an axes1 and it perfectly work, but when I try to implement the same commands to my GUI it fails.
You will notice to the m files I attach, that I have placed the same commands over and over again to almost all the relative callback functions (slider1_Callback, mouseScroll, loadButton, etc) because they were asking for the variables to be stated.
Any help on this?
  1 个评论
Stelios Fanourakis
Stelios Fanourakis 2018-6-10
The slider is not working. It won't move either under wheel scrolling or arrowheads pressing. If it slightly moves, it goes back to the beggining instantly and it won't control the image depicted on the first axes1, it won't alter.

请先登录,再进行评论。

采纳的回答

Jan
Jan 2018-6-11
You are creating a new slider inside the callback of the slider:
handles.SliderFrame = uicontrol('Style','slider','Position',[60 20 400 50], ...
'Min',1,'Max',NumFrames,'Value',1, ...
'SliderStep',[1/NumFrames 2/NumFrames], ...
'Callback',@slider1_Callback);
This hides the formerly existing sliders and sets the slider value to 1 for each call.
Importing the list of files in all slider callbacks is a waste of time in addition.
Solution: Create the slider once only, either in GUIDE or in the OutputFcn (where it is done now already also). Then omit the re-creation by uicontrol.
I suggest to call the slider1_callback from the mouseScroll function.
  27 个评论
Stelios Fanourakis
Stelios Fanourakis 2018-6-17
@Jan. You do helping me a lot with your suggestions. It seems I need to keep on forward myself from now and on. One slider I added on the GUIDE and one slider from uicontrol. When the figure is loading, it shows 2 sliders but only one of them actually works.
Now the bottom slider works but it works to infinity. I want the total range of the slider to be the number of image frames, e.g. 15
Stelios Fanourakis
Stelios Fanourakis 2018-6-17
Debugger will only tell me the error point. It won't solve it.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by