Hi,
I have create the slider which is in the range of 0 to 1 with interval 0.01 and 100 steps. Then, every time I change the slider, the value will display on the static text and save it as .mat file. I have made the value on static text as in 2 decimal point. However, the value got from the slider was different. For instance, the value display on static text is 0.63, but the value from slider is 0.6349. I want my value from the slider exactly same as what display on the static text. What function that I can applied?
This my code:
function slider_threshold_Callback(hObject, eventdata, handles)global Pth% hObject handle to slider_threshold (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'Value') returns position of slider
% get(hObject,'Min') and get(hObject,'Max') to determine range of slider
% set the slider range and step size
set(handles.slider_threshold, 'Min', 0);set(handles.slider_threshold, 'Max', 1);set(handles.slider_threshold, 'SliderStep', [0.01 , 0.99 ]); % 100 steps
%save the current/last slider value as the threshold value
Pth = get(handles.slider_threshold, 'Value');set(handles.Threshold_text,'String', num2str(Pth,'%04.2f'));save ('Pth.mat','Pth'); % Update handles structure
guidata(hObject, handles);
Best Answer