title: Why is MATLAB reporting my variable uninitialized?
body: <p>I made a class and in one of its methods I needed to calculate the distance between two points. So I wrote an ordinary function named "remoteness" to do this for me. </p>
  
  <h3>Compilation Error:</h3>
  
  <blockquote>
    <p>At compilation, "remoteness" was
    determined to be a variable and this
    variable is uninitialized. 
    "remoteness" is also a function name
    and previous versions of MATLAB would
    have called the function.</p>
  </blockquote>
  
  <p>However, MATLAB 7 forbids the use of the same name in the same context as both a function and a variable.</p>
  
  <blockquote>
    <p>Error in ==> TRobot>TRobot.makeVisibilityGraph at 58
        obj.visiblityGraph(k,k+1) = remoteness(:,obj.VGVertices(k),obj.VGVertices(:,k+1));</p>
  </blockquote>
  
  <p>I thought the name <code>remoteness</code> might be a name of another function, but when I changed its name to <code>kamran</code> the error persisted. It should be noted that I can use the <code>kamran</code> function (or <code>remoteness</code>) in the command line without any problem.</p>
  
  <h3>Command line example:</h3>
  
  <pre><code>&gt;&gt; kamran([0,0],[3,4])
  
  ans = 5
  </code></pre>
  
  <p>The code of the <code>kamran</code> function is in a separate m file.</p>
  
  <h3>Code for <code>kamran</code> function:</h3>
  
  <pre><code>function dist = kamran(v1,v2)
      dist = sqrt(    (v1(1) - v2(1)) ^2  + (v1(2) - v2(2)) ^2   );
  </code></pre>
  
  <h3>Code example for how <code>kamran</code> function is used:</h3>
  
  <pre><code>function obj = makeVisibilityGraph(obj)
            verticesNumber = 0; 
            for num = 1: size(obj.staticObstacle,2)
                verticesNumber = verticesNumber + size(obj.staticObstacle(num).polygon,2);
            end
            % in the below line, 2 is for start and goal vertices
             obj.visibilityGraph = ones(2 + size(obj.VGVertices,2)) * Inf;
             for j=1 : size(obj.staticObstacle,2)
                index = size(obj.VGVertices,2);
                obj.VGVertices = [obj.VGVertices, obj.staticObstacle(j).polygon];
                obj.labelVGVertices = [obj.labelVGVertices, ones(1,size(obj.staticObstacle(j).polygon,2))* j ];
                for k = index+1 : (size(obj.VGVertices,2)-1)
                    obj.visiblityGraph(k,k+1) = kamran(:,obj.VGVertices(k),obj.VGVertices(:,k+1));
                end
  %             as the first and last point of a polygon are visible to each
  %             other, so set them visible to each other
                obj.visibilityGraph(index+1,size(obj.VGVertices,2)) = ...
                                 kamran( obj.VGVertices(:,index+1), obj.VGVertices(:,size(obj.VGVertices,2)));
             end     
  
  
  end
  </code></pre>