What is wrong with the code?

1 view (last 30 days)
GEORGIOS BEKAS
GEORGIOS BEKAS on 3 Jan 2018
Edited: Torsten on 3 Jan 2018
I want to remove the vowels and I am doing something wrong.
chr = 'The fast black dog'
for i = 1:length(chr)
if chr(i) == 'a'
chr = erase(chr(i),'a')
elseif chr(i) == 'e'
chr = erase(chr(i),'e')
elseif chr(i) == 'i'
chr = erase(chr(i),'i')
elseif chr(i) == 'o'
chr = erase(chr(i),'o')
elseif chr(i) == 'u'
chr = erase(chr(i),'u')
end
end

Accepted Answer

Torsten
Torsten on 3 Jan 2018
Edited: Torsten on 3 Jan 2018
chr = 'The fast black dog';
match = ["a","e","i","o","u"];
newchr = erase(chr,match)
Best wishes
Torsten.

More Answers (0)

Categories

Find more on Characters and Strings in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!