Q/ write program to read string then print the count of numbers & the number in the string.
Ex: mosul42city6 output: count= 3 num.= 4 2 6

1 comentario

Adam Danz
Adam Danz el 23 de Mzo. de 2021
This is obviously homework. Users of the forum should not be asking for solutions to their homework and volunteers should not be giving full solutions to homework problems.

Iniciar sesión para comentar.

Respuestas (1)

David Hill
David Hill el 23 de Mzo. de 2021

0 votos

a ='mosul42city6';
b=regexp(a,'\d');
count=length(b);
num=a(b)-'0';

4 comentarios

Walter Roberson
Walter Roberson el 23 de Mzo. de 2021
We discourage volunteers from giving complete homework solutions.
John D'Errico
John D'Errico el 24 de Mzo. de 2021
Please don't do homework assignments for people. It does not help them, nor does it help the site, as that just encourages other stuents to post their homework.
David Hill
David Hill el 24 de Mzo. de 2021
Would you like me to delete?
Walter Roberson
Walter Roberson el 24 de Mzo. de 2021
You could rewrite to provide guidance instead of complete code. For example you could describe that regexp with '\d' can be used to locate digits.

Iniciar sesión para comentar.

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 23 de Mzo. de 2021

Comentada:

el 24 de Mzo. de 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by