필터 지우기
필터 지우기

how to remove vowels using matlab ?

조회 수: 5 (최근 30일)
dwi
dwi 2013년 10월 1일
댓글: shivam verma 2018년 12월 2일
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
Walter Roberson
Walter Roberson 2013년 10월 1일
I don't think those are semi-vowels, Andreas :)
Andreas Goser
Andreas Goser 2013년 10월 1일
Ah, I wasn't responding to Walter but was more generally mentioning such strange characters exist.

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

답변 (3개)

Jothi
Jothi 2013년 10월 1일
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
Jan
Jan 2013년 10월 1일
@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 2018년 12월 2일
jothi i think your answer is not working, can you please check again?

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


Jan
Jan 2013년 10월 1일
편집: Jan 2013년 10월 1일
output = s1(~ismember(s1, 'aeiou'));
And considering uppercase vowels:
output = s1(~ismember(lower(s1), 'aeiou'));

Andrei Bobrov
Andrei Bobrov 2013년 10월 1일
편집: Andrei Bobrov 2013년 10월 1일
regexprep(s1,{'a','e','i','o'},repmat({''},1,4))
or
regexprep(s1,'[aeio]','')
  댓글 수: 1
Walter Roberson
Walter Roberson 2013년 10월 1일
Too efficient for a beginner answer. As was the answer I almost posted but decided against a second ago.

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

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by