Your problem is not taking into account the full potential of callbacks. You throw away the handle to the object you're using. Your function should look something like this. (I would also discourage the use of nested functions, as they make it harder to keep track of your variables)
function ploting_misc(hObject,~)
val=hObject.Value;
