title: How do you store text from a .txt file into a cell array in matlab?
body: <p>For this project I am doing, I have to analyze tweets off of a company's twitter page. I took the last thirty tweets of this company, and I put it into a .txt document, where each line is a different tweet. I am supposed to store all of the hashtags in a cell array, and then print out these hashtags to the command window. (The hashtags are supposed to include the phrase or words inside the hashtags as well. for example, #matlab #programming #stackoverflow.) I am really confused on how I would store them into a cell array. This is the code, that I have so far. All it does is count the number of hashtags in the entire file.</p>
  
  <pre><code>%% Collecting the hashtags
  fid=fopen('twitter.txt');
  hashtag=0
  nextLine=(fgetl(fid));
  while ischar(nextLine)
  if regexp(nextLine,'#')
      hashtag=hashtag+length(regexp(nextLine,'#'));
  end
  nextLine=(fgetl(fid));
  end
  </code></pre>
  
  <p>Is there a way to just take the file contents and store it into a cell array with a command, or would I have to manually copy and paste the entire content of the file into something like the variable below and then use a while loop to just access the cell array and use fprintf to print each hashtag out?</p>
  
  <pre><code>hashtagArray={'#...','#..',..}
  </code></pre>