Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Count how many ‘a’ are in str and eliminate those ‘a’

1 Ansicht (letzte 30 Tage)
nty huy
nty huy am 15 Okt. 2019
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
so for ex in a str= i have an apple
and we want to see how many a and remove them we would use
str1= 'a'
ind = strfind(str, str1)
str(ind) = ''
how would we use a loop for this?
  1 Kommentar
Rik
Rik am 15 Okt. 2019
Backup of question in case of edit-delete:
so for ex in a str= i have an apple
and we want to see how many a and remove them we would use
str1= 'a'
ind = strfind(str, str1)
str(ind) = ''
how would we use a loop for this?

Antworten (1)

Daniel M
Daniel M am 15 Okt. 2019
s = 'I have an apple';
[a,b] = regexp(s,'a','split');
numA = length(b);
sentenceWithoutA = strjoin(a);
  5 Kommentare
nty huy
nty huy am 15 Okt. 2019
ok reported :)
Rik
Rik am 15 Okt. 2019
You would probably get a chuckle out of your teacher if you handed in that loop. Also, flagging is not doing what you think. It does attract the attention of site administrators, but it is more likely flags will be dealt with by high reputation members, so exactly the people whose comments you are flagging.

Diese Frage ist geschlossen.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by