Mercurial > hg > machine-learning-hw2
diff plotData.m @ 1:8b902ada47e9
Complete part 1
author | Jordi GutiƩrrez Hermoso <jordigh@octave.org> |
---|---|
date | Sat, 29 Oct 2011 21:03:10 -0500 (2011-10-30) |
parents | 5664e0047b3e |
children | a4c4da8f4ac0 |
line wrap: on
line diff
--- a/plotData.m +++ b/plotData.m @@ -1,28 +1,18 @@ function plotData(X, y) -%PLOTDATA Plots the data points X and y into a new figure -% PLOTDATA(x,y) plots the data points with + for the positive examples -% and o for the negative examples. X is assumed to be a Mx2 matrix. +##PLOTDATA Plots the data points X and y into a new figure +## PLOTDATA(x,y) plots the data points with + for the positive examples +## and o for the negative examples. X is assumed to be a Mx2 matrix. -% Create New Figure +## Create New Figure figure; hold on; -% ====================== YOUR CODE HERE ====================== -% Instructions: Plot the positive and negative examples on a -% 2D plot, using the option 'k+' for the positive -% examples and 'ko' for the negative examples. -% - - - - - - - - - -% ========================================================================= - - +## Find Indices of Positive and Negative Examples +pos = find(y==1); neg = find(y == 0); +## Plot Examples +plot (X(pos, 1), X(pos, 2), "k+","LineWidth", 2, + "MarkerSize", 7); +plot (X(neg, 1), X(neg, 2), "ko", "MarkerFaceColor", + "y", "MarkerSize", 7); hold off;