Hi, I have if statement, to change added value in GUI edit text button if it is greater than 16. Right now it isn't working, what I should change in it? Part of code:
function etfM_Callback(hObject, eventdata, handles)
global fM;
fM = get(hObject,'String');
if fM>16
fM = 'NaN';
set(handles.etfM, 'String', fM);
end

 채택된 답변

Niklas Nylén
Niklas Nylén 2014년 3월 28일
편집: Niklas Nylén 2014년 3월 28일

0 개 추천

fM = get(hObject,'String') will return a string. To compare it to 16 in the if statement you need to convert it to a number. One option is to make the following change:
fM = str2num(get(hObject,'String'))

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Numeric Types에 대해 자세히 알아보기

태그

질문:

ZK
2014년 3월 27일

댓글:

ZK
2014년 3월 28일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by