How to enter letters in edit?

Good day. I have some variable 'a' which I enter in 'edit'-field. I need to enter letters(for example 'B') in that field,but when I do this and try to count something,MATLAB gives me a Callback error and in Workspace I can see that a have a value 'NaN'. What's wrong? And how can I fix it?
a=str2double(get(hI1,'string'))
and in another m.file:
hI1=uicontrol('Style','edit','Position',[220 400 200 30],'String','',...
'backgroundcolor',[0.1 0.1 0.1],'Fontsize',13,'foregroundcolor','w','parent',hW);

1 Comment

A= myData(Boss);
set(handles.displayname,'String',A);
Try with this

Sign in to comment.

Answers (1)

If you enter the letter 'B' in the edit box, then of course, trying to convert it to a number (with str2double) as you've done is not going to produce anything sensible. hence you get NaN (Not a Number).
To fix, don't convert to a number.
a = get(hI1, 'string'); %and use a better variable name than a

Categories

Asked:

on 22 May 2015

Answered:

on 22 May 2015

Community Treasure Hunt

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

Start Hunting!