title: How to use matlab contourf to draw two-dimensional decision boundary
body: <p>I finished an SVM training and got data like X, Y. X is the feature matrix only with 2 dimensions, and Y is the classification labels. Because the data is only in two dimensions, so I would like to draw a decision boundary to show the surface of support vectors. </p>
  
  <p>I use contouf in Matlab to do the trick, but really find it hard to understand how to use the function.</p>
  
  <p>I wrote like:</p>
  
  <pre><code>#1 try:    
  contourf(X);
  
  #2 try:
  contourf([X(:,1) X(:,2) Y]);
  
  #3 try:
  Z(:,:,1)=X(Y==1,:);
  Z(:,:,2)=X(Y==2,:);
  contourf(Z);
  </code></pre>
  
  <p>all these things do not correctly. And I checked the Matlab help files, most of them make Z as a function, so I really do not know how to form the correct Z matrix. </p>