MATLAB: How to create a random distribution of 2 words in 30 places MATLAB I am confused to create the random distribution of the two words such as "mango" and "orange" into 30 places? Best Answer Words = ["mango", "orange"] ;Output = Words(randi(length(Words), 1, 30); Related SolutionsMATLAB: Truss optimization, genetic algorithm That statement does not indicate an error. That indicates normal ending of the solver iterations.Congratulations!Alan WeissMATLAB mathematical toolbox documentation MATLAB: How to count the no of words in a sentence txt = fileread('hello.txt'); %read in file, assuming it is not too bigsentences = strtrim(regexp(txt, '[\.\?\!]+', 'split')); %split into sentences%I assume that sentences end with ., ?, or !, which don't appear elsewhere in % the file (i.e., no quoted strings, abbreviations containing '.', etc.).words = regexp(sentences, '\s+', 'start'); % find spaces (which separate words)wordsPerSentence = cellfun(@length, words, 'UniformOutput', true); %count words%we only care about sentences containing at least one word.wordsPerSentence = wordsPerSentence(wordsPerSentence>=1)+1; Related QuestionHow to compare two sentences with similar wordsHow to fix “unrecognized variable error”-Function to capitalize first letter in each word in string but forces all other letters to be lowercase
Best Answer