MATLAB: How to select the first letter of every word string I have no idea how I would go about doing this Input: I like eating pizza Output: Ilep Best Answer str='I like eating pizza'; str2=cellfun(@(c) c(1),strsplit(str)) Related SolutionsMATLAB: Regexprep() skip first occurrence How about using regexp to find the position of spaces, and delete 2nd~Nth spaces? Like:mystring = 'this is my string';pos = regexp(mystring,'\s');mystring(pos(2:end)) = []; MATLAB: Find common words in 2 strings str1 = ('rabbit is eating grass near a tree');str2 = ('rabbit is sleeping under tree');str=intersect(strsplit(str1),strsplit(str2))OR, to maintain the orderstr=intersect(strsplit(str1),strsplit(str2),'stable') Related QuestionHow to create a random distribution of 2 words in 30 placesHow to convert cell in a stringReplacing Occurrences of StringHow to compare words from two text files and get output as number of matching wordsFunction to capitalize first letter in each word in string but forces all other letters to be lowercase
Best Answer