title: Is there any function to calculate Precision and Recall using Matlab?
body: <p>I have problem about calculating the precision and recall for classifier in matlab. I use fisherIris data (that consists of 150 datapoints, 50-setosa, 50-versicolor, 50-virginica). I have classified using kNN algorithm. Here is my confusion matrix:</p>
  
  <pre><code>50     0     0
   0    48     2
   0     4    46
  </code></pre>
  
  <p>correct classification rate is 96% (144/150), but how to calculate precision and recall using matlab, is there any function? 
  I know the formulas for that precision=tp/(tp+fp),and recall=tp/(tp+fn), but I am lost in identifying components. For instance, can I say that true positive is 144 from the matrix? what about false positive and false negative?
  Please help!!! I would really appreciate! Thank you!</p>