How do I get the integer value from a edit box?
2 ビュー (過去 30 日間)
古いコメントを表示
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);
0 件のコメント
採用された回答
Image Analyst
2016 年 4 月 2 日
Looks like it should work. Why do you say it doesn't?
3 件のコメント
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 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!