title: Sum of all values in matrix (Matlab)
body: <p>So I'm trying to create a matlab function that takes two inputs, a matrix and a value, and returns the sum of all values in the matrix except for all instances of the given value. So far this is the code I have written:</p>
  
  <pre><code>function [total] = sumAllExcept(matrix, except)
      total = 0;
      for i = 1:size(matrix, 1)
          for k  = 1:size(matrix, 2)
              if(matrix(i, k) ~= except)
                  total = total + matrix(i,k);
              end
          end
      end
  end
  </code></pre>
  
  <p>The error message that I am receiving when trying to run the program is:
  " Undefined function 'sumAllExcept' for input arguments of type 'double'. "
  I would greatly appreciate it if you would show me whats wrong with this and fix anything that you can.  Thank you!</p>