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
John D'Errico
2017년 9월 7일
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.
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.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!