필터 지우기
필터 지우기

How do I get the integer value from a edit box?

조회 수: 2 (최근 30일)
Recap
Recap 2016년 4월 2일
댓글: Image Analyst 2016년 4월 2일
The only way I know of getting the value of an edit box is getting it as a string. How do I assign it as an integer. My edit box input is '123'. How do I retrieve it and store and an integer. I tried the code below but it didnt work
widthBox=get(handles.edit5,'String');
ws = str2num(widthBox);

채택된 답변

Image Analyst
Image Analyst 2016년 4월 2일
Looks like it should work. Why do you say it doesn't?
  댓글 수: 3
Recap
Recap 2016년 4월 2일
Its ok now, im using str2double and it seems to do the job.
Image Analyst
Image Analyst 2016년 4월 2일
perhaps it's a cell, which might happen if you have the max property set to bigger than 1. So try to use char() or cell2mat() to cast it to a character.
editBoxContents = get(handles.edit5,'String');
ws = str2double(char(editBoxContents));
% or
ws = str2double(cell2mat(editBoxContents));

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by