Azzera filtri
Azzera filtri

What is wrong with the code?

2 visualizzazioni (ultimi 30 giorni)
GEORGIOS BEKAS
GEORGIOS BEKAS il 3 Gen 2018
Modificato: Torsten il 3 Gen 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

Risposta accettata

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

Più risposte (0)

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by