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

Adam Danz
Adam Danz 2021년 3월 23일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

David Hill
David Hill 2021년 3월 23일

0 개 추천

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

댓글 수: 4

Walter Roberson
Walter Roberson 2021년 3월 23일
We discourage volunteers from giving complete homework solutions.
John D'Errico
John D'Errico 2021년 3월 24일
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 2021년 3월 24일
Would you like me to delete?
Walter Roberson
Walter Roberson 2021년 3월 24일
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.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

질문:

2021년 3월 23일

댓글:

2021년 3월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by