title: Calculate the sigmoid function
body: <p>I am  learning about machine learning from coursera. I am trying to calculate the sigmoid function and i have the below code:</p>
  
  <pre><code>function g = sigmoid(z)
  %SIGMOID Compute sigmoid functoon
  %   J = SIGMOID(z) computes the sigmoid of z.
  
  % You need to return the following variables correctly 
  
  g = zeros(size(z));
  
  % ====================== YOUR CODE HERE ======================
  
  % Instructions: Compute the sigmoid of each value of z (z can be a matrix,
  %               vector or scalar).
  
  
  
  g = (1 + exp(-1 * z)) .^ -1;
   g = 1/(1+ (1/exp(z)))
  
  
  % my question is why the first g calculation works for matrix(say 100*2) however the second only works for (100*1) as both are trying to do the same this.
  
  
  % =============================================================
  
  end
  </code></pre>