Scilab 6.0.2
- Scilab Help
- Strings
- ascii
- asciimat
- blanks
- char
- convstr
- emptystr
- eval
- evstr
- grep
- isalphanum
- isascii
- isdigit
- isletter
- isnum
- justify
- length
- part
- prettyprint
- regexp
- sci2exp
- strcat
- strchr
- strcmp
- strcmpi
- strcspn
- strindex
- string
- strings
- stripblanks
- strncpy
- strrchr
- strrev
- strsplit
- strspn
- strstr
- strsubst
- strtod
- strtok
- tokenpos
- tokens
Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
See the recommended documentation of this function
strtod
parse and convert literal numbers STRings TO Decimal numbers
Syntax
d = strtod(str [,decimalseparator]) [d, tails] = strtod(str [,decimalseparator])
Arguments
- str
single component, vector, or matrix of text (strings).
- decimalseparator
the decimal separator chosen: "." (by default) or ",".
- d
scalar, vector, or matrix of decimal numbers.
- tails
a string or matrix of strings: remaining parts of
str
after the numerical heads (if any).
Description
[d, tails] = strtod(str)
parses each string of
str
and tries to interpret its content as a decimal
number:
- If it succeeds, at least for the heading part of
str(i)
, the corresponding decimal number is returned ind(i)
. If any, the trailing part ofstr(i)
is ignored and returned intails(i)
; otherwise,tails(i)
returns "". - Otherwise,
d(i)
returns%nan
, andtails(i)
is the wholestr(i)
.
|
Examples
s = ["123.556 abc " ".543" "#58B" "0x73 " "%inf" "-1.47e-71" "67,432.57" " 23,5" "-,57" "Inf" ] [num, trail] = strtod(s); num, "/"+trail+"/" // With "," as decimal separator: [num, trail] = strtod(s, ","); num, "/"+trail+"/"
See also
- evstr — evaluates Scilab expressions and concatenates their results
- isnum — tests if a string represents a number
- isdigit — check that characters of a string are digits between 0 and 9
- bin2dec — convert from binary to decimal
- oct2dec — convert from octal to decimal
- hex2dec — convert from hexadecimal to decimal
History
Version | Description |
5.5.0 | Option decimalseparator introduced (SEP 97). |
5.4.1 | If str does not contain any numerical value,
d now returns Nan
instead of 0 . |
Report an issue | ||
<< strsubst | Strings | strtok >> |