title: MATLAB store value of looping to table form
body: <p>I have the following working code which display parameter count after each hour. The code use two function. Basically my code does</p>
  
  <ul>
  <li>User run test_main(hour, total parameter)</li>
  <li>test_main generate random number</li>
  <li>test_main send number to test_sub</li>
  <li>test_sub respond to the number</li>
  </ul>
  
  <p>test_main function</p>
  
  <pre><code> function[] = test_main(x, pc)
  
  for i = 1:x %loop for time
      fprintf('\n Time is %d hour after count start .  \n', i);
  
      for t = 1:pc
          fprintf('\nPARAMETER at test main %d ', t);
  
          w=rand; %random error generator. 
          if w&lt;0.5 
              status=1;
          else
              status=99; 
          end
  
      % fprintf('\n Time is %d hour after count start .  \n', i);
  
      test_sub(status);
      end  
  end
  end
  </code></pre>
  
  <p>test_sub function</p>
  
  <pre><code>function[a] = test_sub(z)
  
  %fprintf('\nPARAMETER inside test sub %d ', count)
  fprintf('\n Value is %d \n', z);
  
      if (z==1) %if input equal to 0
       j=1; %store temporary value to j
       a=j; 
       disp('new value is 1')
  
      elseif (z==99)
       j=1;
       a=j;
       disp('new value is 100')
  else
  disp('unidentified error')
  end
  end
  </code></pre>
  
  <p>I notice that i haven't send a value back from test_sub to test_main. Im not sure how to record the value after each loop into table form. I need the table looks like:</p>
  
  <pre><code>         Parameter 1    Parameter 2   ..... parameter N
  Time 1        1             100
  Time 2       100             1
  ....
  Time N
  </code></pre>
  
  <p>Can the parameter and time expand according to the value that user insert at the test_main function?</p>