MATLAB: Replace character with another charactercodecommandMATLABpeclacestring Hello. Which command should I use in order to replace one character with another? (For example in the word: Big, I would like to replace character i with a.) Best Answer S = 'Big'S = 'Big'S(S == 'i') = 'a'S = 'Bag'T = 'Big'T = 'Big'T = strrep(T, 'i', 'a')T = 'Bag'U = 'Big'U = 'Big'U = regexprep(U, 'i', 'a')U = 'Bag' Related SolutionsMATLAB: How to replace an entire word with another Try this:str = 'b4 b4n';out = regexprep(str, '\<b4\>', 'before');out = regexprep(out, '\<b4n\>', 'before now')out =before before now MATLAB: Replacing String Values By Position You don't need to use linear indexing (STRFIND) here at all. Just use logical indexing.str = 'test rest';str(str=='e')='r' Related QuestionRenaming categories with accentsRemove/replace ‘ i.e single quote from a sentance …Replacing only certain instances of text within matlab character arrayFind and Replace Overlapping SubstringsReplace repeated symbol by regexprep
Best Answer