MATLAB gui 界面设计过程中遇到的问题及解决方法
MATLAB版本r2014a
1.滑块的回调函数如下,功能:得到K的值,并将K值显示到静态文本中(K值为整数)
function slider_val_Callback(hObject, eventdata, handles)
% hObject handle to slider_val (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
val=get(hObject,'Value');
if rem(val,1)~=0
set(handles.txt_display,'String',num2str(round(val)));
end
global K;
K=round(val);