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

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

"It is not working" is not useful for a discussion.
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

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

Instead of programming these thing individually why not use the MATLAB GUIDE which you can drag and drop all your UI objects.
i have used the commands to set next edit box but results are not coming. all values of sliders are shown in only first edit box. i have programmed for 2nd slider as well can anyone please tell me how can i add another edit box in my programming and where i m doing mistake why cant i get a separate edit box for each slider. Modified coding is attached
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))
with this you only need one edit_val function as each are created when the GUI opens.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!