title: Matlab function return value
body: <p>I have one program that has function and the problem, return value, it has too many output. </p>
  
  <p>Like exempley: y = text the answer comes up </p>
  
  <pre><code>Error in text (line 2)
  
  if nargin == 0 
  
  Output argument "array" (and maybe others) not assigned during call to "
  C:\Users\name\Documents\MATLAB\text.m&gt;text".
  </code></pre>
  
  <p>The program text.m reads a txt file that contains a couple of names and numbers like</p>
  
  <p>exemple:</p>
  
  <p>John doughlas 15986</p>
  
  <p>Filip duch 357852</p>
  
  <p>and so on. The program convert them to 15986 Doughlas John and so on.</p>
  
  <pre><code>function array = text(~) 
  if nargin == 0 
  dirr = '.';
  end
  answer = dir(dirr);  
  k=1;
  while k &lt;= length(answer) 
      if answer(k).isdir 
          answer(k)=[]; 
      else
          filename{k}=answer(k).name;
          k=k+1;
      end
   end
  chose=menu( 'choose file',filename);
  namn = char(filename(chose));  
  fid = fopen(namn, 'r');    
  R = textscan(fid,'%s %s %s');  
  x=-1;                                            
  k=0;                                               
  while x &lt;= 24                                  
        x = k + 1;                                    
        All = [R{3}{x},'   ',R{1}{x},' ',R{2}{x}];
        disp(All)                                     
        k = k + 1;                                   
  end                                                
  fclose(fid);
  </code></pre>
  
  <p>Is there anyway to fix the problem without starting over from scratch?</p>
  
  <p>Grateful for all the answers!</p>