- double
- string
- char
- something else?
differentiate input dialog strings into either symbols or double precision values
조회 수: 2 (최근 30일)
이전 댓글 표시
I have an input dialog box where I put values or a variable I am trying to solve for. Problem I have is how do I have Matlab differentiate between numeric inputs so I can convert them to double string values or alphabet values so I can tell MATLAB that something like sigma_x is a symbol?
댓글 수: 2
답변 (1개)
Stephen23
2017년 11월 19일
편집: Stephen23
2017년 11월 19일
There are several ways your could approach this, depending on what you define as "numeric" (e.g. plus/minus sign, decimal digits, exponent notation, etc). The simplest to try would be to use str2double, which returns NaN if the input cannot be converted to double:
num = str2double(str);
if isnan(num)
% str is a "symbol"
else
% num is numeric value
end
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!