how to remove vowels using matlab ?

16 visualizaciones (últimos 30 días)
dwi
dwi el 1 de Oct. de 2013
Comentada: shivam verma el 2 de Dic. de 2018
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 comentarios
Walter Roberson
Walter Roberson el 1 de Oct. de 2013
I don't think those are semi-vowels, Andreas :)
Andreas Goser
Andreas Goser el 1 de Oct. de 2013
Ah, I wasn't responding to Walter but was more generally mentioning such strange characters exist.

Iniciar sesión para comentar.

Respuestas (3)

Jothi
Jothi el 1 de Oct. de 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 comentarios
Jan
Jan el 1 de Oct. de 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
shivam verma
shivam verma el 2 de Dic. de 2018
jothi i think your answer is not working, can you please check again?

Iniciar sesión para comentar.


Jan
Jan el 1 de Oct. de 2013
Editada: Jan el 1 de Oct. de 2013
output = s1(~ismember(s1, 'aeiou'));
And considering uppercase vowels:
output = s1(~ismember(lower(s1), 'aeiou'));

Andrei Bobrov
Andrei Bobrov el 1 de Oct. de 2013
Editada: Andrei Bobrov el 1 de Oct. de 2013
regexprep(s1,{'a','e','i','o'},repmat({''},1,4))
or
regexprep(s1,'[aeio]','')
  1 comentario
Walter Roberson
Walter Roberson el 1 de Oct. de 2013
Too efficient for a beginner answer. As was the answer I almost posted but decided against a second ago.

Iniciar sesión para comentar.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by