title: how to iterate through rows and columns of a matrix in matlab in a specified user defined function
body: <p>This is from my instructor.  I need help with the particular coding below involving iterating through the rows and of the columns in a previously determined array.  colNum = 20 and rowNum 10. Also the tempToColor function is already defined and working and it creates a 101x3 matrix each row giving a different color shade according to a temperature between 0-100 degrees.</p>
  
  <p>"This function has a finElems parameter and doesn't return anything. It plots all the temperature values found in the finElems array. You can see my example plot below. To plot a color, use a statement like this:</p>
  
  <pre><code>plot(colNum, numRows-rowNum, 's', 'Color', color, 'MarkerFaceColor', color, 'MarkerSize', 20);
  </code></pre>
  
  <p>In order to use this statement you should create a few variables:colNum:This is the current column number
  .You will iterate through all the columns in the array, so store the current column number in this variable.
  rowNum: Same as colNum, except it's the current row number.
  •color:This is the color of the current finElems element as determined by the function tempToColor
  .I found it necessary to use the expression numRows - rowNum so that the bottom row of the array (the highest numbered row) appears as the bottom row on the graph. Otherwise the fin appears upside down in the graph. Use this outline for the function: </p>
  
  <pre><code>function plotFin(finElems)
  
  hold on;
  
  % iterate through all the rows:
  
  % iterate through all the columns: (this is a loop within a loop)
  
  % Use the tempToColor function to get the temperature.
  
  % Plot the temperature color.
  
  % end
  
  % end
  
  axis equal tight;
  
  axis([0 (numCols+1) -1 numRows]);
  
  hold off;
  
  end
  </code></pre>