plotData.m 569 B

1234567891011121314151617
  1. function plotData(X, y)
  2. %PLOTDATA Plots the data points X and y into a new figure
  3. % PLOTDATA(x,y) plots the data points with + for the positive examples
  4. % and o for the negative examples. X is assumed to be a Mx2 matrix.
  5. %
  6. % Note: This was slightly modified such that it expects y = 1 or y = 0
  7. % Find Indices of Positive and Negative Examples
  8. pos = find(y == 1); neg = find(y == 0);
  9. % Plot Examples
  10. plot(X(pos, 1), X(pos, 2), 'k+','LineWidth', 1, 'MarkerSize', 7)
  11. hold on;
  12. plot(X(neg, 1), X(neg, 2), 'ko', 'MarkerFaceColor', 'y', 'MarkerSize', 7)
  13. hold off;
  14. end