change fuction from if to switch statement
1 次查看(过去 30 天)
显示 更早的评论
% --- Executes during object creation, after setting all properties.
function sliderText_CreateFcn(hObject, ~, ~)
% hObject handle to sliderText (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
%sets the slider value to start at 1
set(hObject,'String', 1);
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
2 个评论
Rik
2020-4-29
What exactly do you want to change? I would suggest not using GUIDE in the first place, but which if do you want to replace with a switch?
Walter Roberson
2020-4-29
%sets the slider value to start at 1
set(hObject,'String', 1);
That is incorrect. String property for a slider is the label, not the value range or current value. The lowest permitted value is controlled by the slider Min property, and the highest permitted value is controlled by the slider Max property, and the current value is controlled by the slider Value property.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!