How to error check a string for numbers?
15 ビュー (過去 30 日間)
古いコメントを表示
So I have an input
name = input('Please enter your name:\n', 's');
How can I error check so that a user cannot enter any numbers for it?
2 件のコメント
回答 (1 件)
KSSV
2018 年 10 月 15 日
name = input('Please enter your name:\n', 's');
if isnan(str2double(name))
fprintf('Input is a string\n')
end
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!