StringIsNumber

STRINGISNUMBER returns 1 if the input string contains only a number and otherwise a zero.

您现在正在关注此提交

STRINGISNUMBER returns 1 if the input string contains only a number and otherwise a zero

Created as an example for the thread "How to determine if an inputfield contains chars or numbers ?"

USAGE:
>> StringIsNumber('aseea')
ans = 0
>> StringIsNumber('333')
ans = 1
>> StringIsNumber('333.123')
ans = 1
>> StringIsNumber('.123')
ans = 1
>> StringIsNumber('0.123')
ans = 1
>> StringIsNumber('0.123a')
ans = 0

IT'S NOT FANCY BUT IT WORKS

引用格式

Michael Robbins (2026). StringIsNumber (https://ww2.mathworks.cn/matlabcentral/fileexchange/6283-stringisnumber), MATLAB Central File Exchange. 检索时间: .

类别

Help CenterMATLAB Answers 中查找有关 Characters and Strings 的更多信息

一般信息

MATLAB 版本兼容性

  • 兼容任何版本

平台兼容性

  • Windows
  • macOS
  • Linux
版本 已发布 发行说明 Action
1.0.0.0

Digits followed by a period but no more digits is now considered a number.

A single period is no longer considered a number.

Vector inputs and outputs are supported.