why is a variable NaN and not a double

i am reading a value from a text field in a form and converting it from a string to a double:
dt=str2double(get(handles.dt,'String')); %time step in ms
there are several other values being read and they are all fine, only this one is giving me grief. after it is read in, i inspect dt and see Nan over 100. the logic refuses to accept it as a double, and using dt to assign a value to t fails: t=dt;
Is there some parameter in the text field properties that prevent the string to double conversion from working. I am a bit of a newbie and can't find anything wrong.
Can someone assist?

2 Comments

It would help if you might show the string itself.
If it is a complicated string, then attach it as a .mat file to your question or a comment.
Guillaume
Guillaume on 7 Sep 2017
Edited: Guillaume on 7 Sep 2017
As John says, show us the content of a string that fails to be converted correctly.
I do not understand: "i inspect dt and see Nan over 100". dt is always going to be a double after the call to str2double. Its value is going to be a scalar floating point value or NaN. handles.dt is a handle to a uicontrol. Nothing can be "NaN over 100", whatever that means.

Sign in to comment.

Answers (0)

Categories

Asked:

on 7 Sep 2017

Edited:

on 7 Sep 2017

Community Treasure Hunt

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

Start Hunting!