MATLAB: How to split a string and assign new values to the strings look up tablestrings If if want to change the string str='Hello' Into a new string with the values str='Hotel-Echo-Lima-Lima-Oscar' How do I do that? Best Answer This is even simpler, using the newly introduced replace (R2016b):natoLookup = {'h','Hotel-'; 'e','Echo-'; 'l','Lima-'; 'o','Oscar-'; };replace(lower('Hello'), natoLookup(:, 1), natoLookup(:, 2)) Related SolutionsMATLAB: Function to capitalize first letter in each word in string but forces all other letters to be lowercase str='this is a tEST';str=lower(str)idx=regexp([' ' str],'(?<=\s+)\S','start')-1str(idx)=upper(str(idx)) MATLAB: How to replace double quotes with two single quotes in string in MATLAB (R2013a) Here is an example using both REGEXPREP and STRREP to replace double quotes with two single quotes:>> mystr = 'Hello "Jonathan" ';>> newStr1 = regexprep('Hello "Joe"','"','\''''') % single quote, backslash, 5 single quotesnewStr1 = Hello 'Joe'>> newStr2 = strrep('Hello "Joe"','"','''''') % 6 single quotesnewStr2 = Hello 'Joe' Related QuestionReplacing only certain instances of text within matlab character arrayDisplaying All the Related Items from an Input FileFind index of pattern match
Best Answer