Function Counter of digits
Ältere Kommentare anzeigen
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?
Akzeptierte Antwort
Weitere Antworten (1)
Azzi Abdelmalek
am 20 Mai 2016
Bearbeitet: Azzi Abdelmalek
am 20 Mai 2016
name='w1o4rd12'
out=numel(regexp(name,'\d+'))
%or
name='w1o4rd12'
a=name-'0'
idx=a>=0 & a<=9
out=nnz(idx)
Kategorien
Mehr zu Environment and Settings finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!