Converting a vertical text file into a character array for use in a Word Cloud

Technical Source
2 min readApr 9, 2022

Im trying to read in this file so that it becomes a cell array of strings, so that I can combine with a cell array of corresponding occurances into a table for use in the wordcloud function. I can’t seem to figure out how to read it in and manipulate it so that each word in the list is a string like a normal string cell array.

Any suggestions?

thanks

NOTE:-

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

filename = 'YourFile.txt'
S = regexp( fileread(filename), '\r?\n', 'split');
S(cellfun(@isempty,S)) = []; %remove empty lines, especially at the end

Now S will be a cell array of character vectors. It will not be a cell array of string objects because MATLAB uses either cell array of character vectors, or else uses string() arrays. You can convert it to a string array by using string(S)

SEE COMPLETE ANSWER CLICK THE LINK

--

--

Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.