I used 5 sliders in which values of 1st is changing in edit box. Others are not changing. Coding attached.

1 view (last 30 days)
i want to add edit box for each slider separately but if we continue coding with defined functions for each slider its not showing separate edit box for each slider rather the values are represented only in the 1st box for each slider please tell me how can i add different edit box for each slider. Also I have changed the position of edit box 2 for slider 2 but its not working.
  3 Comments
Jan
Jan on 6 Apr 2014
No, Mina, I did not. Did you get an error message or do the results differ from your expectations?
You do add different edit boxes for each slider every time the callback is called. But you add all these boxes at the same position [580 430 100 30]. It looks strange to add a new box instead of updating the string of an existing box only. Your code is hard to read due to the missing standard indentation and a lot of out-commented code.
What exactly is your question? Could you narrow down the piece of code which does not work as expected?

Sign in to comment.

Accepted Answer

Joseph Cheng
Joseph Cheng on 7 Apr 2014
Just as you created each pushbutton and slider individually you should also create each edit box as well. Then pass the handle as done with {@edit_val,Slider1} but include the edit box handles which you can set with set(editboxhandle,'String',num2str(_______)) where the ___ is the number you want to set the editbox with.
  4 Comments
Joseph Cheng
Joseph Cheng on 7 Apr 2014
It doesn't sound like you read my response.
text1 = uicontrol('Style', 'text', 'String', 0,...
'Position', [580 30 100 30]);
text2 = uicontrol('Style', 'text', 'String', 0,...
'Position', [580 130 100 30]);
text3 = uicontrol('Style', 'text', 'String', 0,...
'Position', [580 230 100 30]);
text4 = uicontrol('Style', 'text', 'String', 0,...
'Position', [580 330 100 30]);
text5 = uicontrol('Style', 'text', 'String', 0,...
'Position', [580 430 100 30]);
can be inserted into the main code and you can change edit_val to this below.
function edit_val(hobject, event,Slider1,text1)
set(text1,'String',num2str(rando))

Sign in to comment.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!