MATLAB: Detect every second character from a string 2nd characterstring How can I detect every second character of a string? Thanks in advance! Best Answer This counts spaces & punctuation as characters (starting with the 1st character). string_var = 'The sun is shining. I feel good.'; answer = string_var(1:2:end)This eliminates periods: string_var = 'The sun is shining. I feel good.'; string_var(string_var == '.') = ''; answer = string_var(1:2:end)Change the . to whatever character you want to eliminate. You want a space. Related SolutionsMATLAB: How to define string character It creates a string (character array) containing just a single space character. MATLAB: How to delete the first or the first two characters in a string string(1:2) = [] % To remove the firt two elements Related QuestionHow to convert char array to string array in MATLAB2103bModify choices for a ListBox CallbackHow to split a StringUnique characters in a cell
Best Answer