title: Octave - find roots and count them
body: <p>I have the equation:</p>
  
  <p><strong>sin(x) = exp(a)+4</strong></p>
  
  <p>x = 1:.1:20</p>
  
  <p>a = 0.02</p>
  
  <p>I know i can use roots or fzero functions inside a loop to determine the roots.</p>
  
  <p>How to use one or both of the above functions to find all the roots and them count them all in <strong>sin(x) = exp(a)-4</strong></p>
  
  <p>I wrote this code, it finds the zeros with fzero and marks them in plot. But how to modify to sin(x) = exp(a)-4 so <strong>finds all roots and then counts the number of finded roots</strong> and output the results.</p>
  
  <pre><code>x = 0:.1:20;
  f = @(x) sin(x) + 4;
  c = zeros(length(x),1);
  for i=0:length(x)
      c = fzero(f,i);
      axis([0, 20, -2, 1])
      plot(x, f(x));
      title('Zeros de f(x) = sin(x) + 4');
      hold on
      plot(c, f(c),'-xr')
      hold on
  end
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>I used fzero inside a loop with the unique function to output, but it never outputs just the unique values. I outputs all duplicates. Anyone know why?</p>
  
  <p>My new code:</p>
  
  <pre><code>h = @(x) cos(x);
  g = @(x) exp(a*x)-1;
  
          f = @(x) h(x) - g(x);
          v = zeros(length(x),1);
          for i=0:length(x)
              v = fzero(f,i);
              [s] = unique(v)
          end
  </code></pre>