title: How to read strings from file with sscanf or fscanf?
body: <p>So, of course, I'm having a little trouble right now. I'm trying to read a text file that goes something like this in a columnar order. What I would like to do is store the number, character and string columns seperately in arrays.</p>
  
  <pre><code>[Numbers] [Characters] [Strings] 
  </code></pre>
  
  <p>Now, while I have figured out how to read the number and character columns into their own arrays, I cannot seem to do so with the string column. At least, not with <code>fscanf</code> or <code>sscanf</code>, which are the commands I want to use. </p>
  
  <p>How can you read a file organized as such using <code>fscanf</code> or <code>sscanf</code>? (I know about textscan, I want to know if this is possible with fscanf or sscanf). </p>
  
  <p>Okay let me add a little code here. So while I was researching this I tried out the following: </p>
  
  <pre><code>fid = fopen('Data.txt', 'w+'); 
  i = 1;
  while ~feof(fid)
       line = fgets(fid);
       M(i) = sscanf(line, '%d, %c, %s', [3,inf];
       i = i+1; 
  end
  </code></pre>
  
  <p>This runs, but M ends up coming out only as a row vector consisting of the first column of numbers in the data file. It just completely ignores the existence of chars and strings. </p>
  
  <p>Now, to get a better understanding of the sscanf function I tried the following </p>
  
  <pre><code>fid = fopen('Data.txt', 'w+'); 
      i = 1;
      while ~feof(fid)
           line = fgets(fid);
           M(i) = sscanf(line, '%d, %d, %d', [3,inf];
           i = i+1; 
      end
  </code></pre>
  
  <p>For a sample set of data consisting of just columns of numbers. This, incidentally, does exactly the same thing as previously; it just reads the first number column of the data and quits. So, I don't even know how to use sscanf, feof, or fgets properly, basically. So I could also use some help here as well.</p>
  
  <p>And I know trying to read just columns of numbers is trivial with fscanf, but I'm trying to understand sscanf and fgets here.  </p>