MATLAB: How to define random values of slider

guislider

how to define random values of slider by varying it and show in text box? In my coding it shows only the value 1. Coding is attached.

Best Answer

This will be a 2 part solution. To answer your only get 1 you'll need to do something like this.
Button1 = uicontrol('Style', 'pushbutton', 'String', 'Run',...
'Position', [450 30 100 30],'Callback', {@edit_val,Slider1});
and then add an additional input to the function.
function edit_val(hobject, event,Slider1)
You are correct and the uicontrol passes the hobject and event, but those are for the uicontrol you are creating. Here the edit_val is not getting slider and event for the specified slider1. It is receiving the hobject and event for the associated pushbutton. I've included the Slider1 to pass the handle for slider1. Since we did that we need to add it to the function as an additional input.
I'm still thinking on how to get the random numbers within the sliders.