how to remove vowels using matlab ?
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
pleas help me to answer this following question :
Remove all the vowels in the given phrase.
Example:
Input s1 = 'Jack and Jill went up the hill'
Output s2 is 'Jck nd Jll wnt p th hll'
6 Kommentare
Andreas Goser
am 1 Okt. 2013
Ah, I wasn't responding to Walter but was more generally mentioning such strange characters exist.
Antworten (3)
Jothi
am 1 Okt. 2013
vow={'a','e','i','o','e'};
s1 = 'Jack and Jill went up the hill'
for i=1:5
output = strrep(s1, vow{i}, '');
s1=output;
end
output =
Jck nd Jll wnt up th hll
2 Kommentare
Jan
am 1 Okt. 2013
@Jothi: vow need not be a cell. strrep is efficient, but this is an alternative:
vow = 'aeioe';
s1 = 'Jack and Jill went up the hill'
for k = 1:5
s1(s1 == vow(k)) = [];
end
Andrei Bobrov
am 1 Okt. 2013
Bearbeitet: Andrei Bobrov
am 1 Okt. 2013
regexprep(s1,{'a','e','i','o'},repmat({''},1,4))
or
regexprep(s1,'[aeio]','')
1 Kommentar
Walter Roberson
am 1 Okt. 2013
Too efficient for a beginner answer. As was the answer I almost posted but decided against a second ago.
Siehe auch
Kategorien
Mehr zu Historical Contests finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!