MATLAB: How to split strings equally with a rest split string equally i want to split a string in equal parts like in this example:input='abcdefghijk' output='abc def ghi jk' Best Answer input_string ='abcdefghijk' % don’t use variable name as input because it may contradict with built-in functionns = numel(input_string);n = 3;Output = cellstr(reshape([input_string repmat(' ',1,ceil(ns/n)*n-ns)],n,[])')' % as cellOutput = char(Output) % as char Related SolutionsMATLAB: How to compare strings in a cell Try this%%Sample datastr = char(randi(double(['A','Z']),[20,3] )); % Too smartcac = mat2cell( str, ones(1,20),3 );R = cac';input_string = R{13};%%Check if input_string exists in R ismember( input_string, R )returnsans = 1 MATLAB: Check if a palindrome. Looks almost identical to a question I answered a few days ago http://www.mathworks.com/matlabcentral/answers/123671#answer_131334. You need to cast to lower case and remove spaces. You can use inputdlg() to ask the user for several strings at a time and get a cell array. Related QuestionHow to treat NaN elements in a cell array as a string in any release of MATLABStrings ASCII and character mapping QuestionsStrcat including space (i.e, ‘ ‘)
Best Answer