MATLAB: How to add variables into a string within a tableMATLABI have a table with a column of 10 digit strings that I need to add "-" into. How do I turn a column of strings looking like this "0001336363" into a column of strings looking like this "0001336-36-3"? Best AnswerThe only option appears to be to turn the string variable into a char array first: str = "0001336363";strc = char(str);Out = sprintf("%7s-%2s-%s", strc(1:7),strc(8:9),strc(10))producing: Out = "0001336-36-3". Related Question”insertAfter” command does not workCharacter String and VariablesFilter a cell array with wordsRegexprep() skip first occurrenceGetting index from strsplit or strfind in a null (00) terminated stringHow to split a string at apostrophe using strsplitHelp with graph legend.
Best Answer