title: Unrecognized function or variable 'f' error
body: <p>I am new to Matlab and I am trying to implement Hough transform without using Matlab builtin function; hence I am learning possible ways to do so. I found a function written in a book that seems to be correct. I got an error and cannot figure it out. </p>
  
  <p>I want to implement hough transform function and later apply it on to a grayscale image</p>
  
  <pre><code>% This functions makes use of sparse matrices
  
  
  function [h, theta, rho] = HT(f, dtheta, drho)
  % [H, THETA, RHO] = HOUGH(F, DTHETA, DRHO) computes the hough
  % transform of the image F. DTHETA specifies the spacing (in degrees) of
  % the the hough transform bins along the theta axis.
  % DRHO specifies the spacing of the hough transform bins along the rho
  % axis. H is the Hough transform matrix. It is NRHO-by-NTHETA, where 
  % NRHO = 2*ceil(norm(size(F))/DRHO) - 1, and NTHETA = 2*ceil(90/DTHETA).
  
  if nargin &lt; 3
    drho = 1;
  end
  if nargin &lt; 2
    dtheta = 1;
  end
  f = double(f);
  [M,N] = size(f);
  theta = linspace(-90, 0, ceil(90/dtheta) + 1);
  theta = [theta -fliplr(theta(2:end - 1))];
  ntheta = length(theta);
  D = sqrt((M - 1)^2 + (N - 1)^2);
  q = ceil(D/drho);
  nrho = 2*q - 1;
  rho = linspace(-q*drho, q*drho, nrho);
  [x, y, val] = find(f);
  x = x - 1; y = y-1;
  %Initialize output.
  h = zeros(nrho, length(theta));
  % To avoid excessive memory usage, process 1000 nonzero pixel 
  % values at a time.
  
  for k = 1:ceil(length(val)/1000)
     first = (k-1)*1000 + 1;
     last = min(first+999, length(x));
     x_matrix = repmat(x(first:last), 1, ntheta);
     y_matrix = repmat(y(first:last), 1, ntheta);
     val_matrix = repmat(val(first:last), 1, ntheta);
     theta_matrix = repmat(theta, size(x_matrix, 1), 1)*pi/180;
     rho_matrix = x_matrix.*cos(theta_matrix) + ...
        y_matrix.*sin(theta_matrix);
  slope = (nrho - 1)/(rho(end) - rho(1));
  rho_bin_index = round(slope*(rho_matrix - rho(1)) + 1);
  theta_bin_index = repmat(1:ntheta, size(x_matrix, 1), 1);
  
  h = h + full(sparse(rho_bin_index(:), theta_bin_index(:), ...
      val_matrix(:), nrho, ntheta));
  end
  
  %Illustration of Hough transform on a simple binary image
  f = zeros(101, 101);
  f(1, 1) = 1; f(101, 1) = 1; f(1, 101) = 1;
  f(101, 101) = 1; f(51, 51) = 1;
  
  % Compute &amp; display the hough
  
  
  H = HT(f);
  imshow(H, [])
  %Label the axis
  [H, theta, rho] = HT(f);
  imshow(theta, rho, H, [ ], 'notruesize')
  axis on, axis normal
  xlabel('\theta', ylabel('\rho'))
  </code></pre>
  
  <p>I expect the hough transform to be displayed using imshow but I get this error </p>
  
  <p>HT(f, dtheta, drho)
  Unrecognized function or variable 'f'.</p>