Function Counter of digits
古いコメントを表示
I am new to Matlab and I want to make a function called digit_counter that takes the name of a text file as input and returns the number of digits (i.e., any of the characters, 0-to-9) that the file contains. Any help?
採用された回答
その他の回答 (1 件)
Azzi Abdelmalek
2016 年 5 月 20 日
編集済み: Azzi Abdelmalek
2016 年 5 月 20 日
name='w1o4rd12'
out=numel(regexp(name,'\d+'))
%or
name='w1o4rd12'
a=name-'0'
idx=a>=0 & a<=9
out=nnz(idx)
カテゴリ
ヘルプ センター および File Exchange で Environment and Settings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!