1
0
Fork 0
This repository has been archived on 2019-12-21. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
coursera-ml-007-exercises/ex2/plotData.m

27 lines
715 B
Mathematica
Raw Normal View History

2014-10-13 22:56:53 +02:00
function plotData(X, y)
2014-10-13 23:03:23 +02:00
%PLOTDATA Plots the data points X and y into a new figure
2014-10-13 22:56:53 +02:00
% 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
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.
%
2014-10-13 23:03:23 +02:00
pos = find(y==1);
neg = find(y==0);
2014-10-13 22:56:53 +02:00
2014-10-13 23:03:23 +02:00
plot(X(pos, 1), X(pos, 2), 'k+');
2014-10-14 10:19:09 +02:00
plot(X(neg, 1), X(neg, 2), 'ro');
2014-10-13 22:56:53 +02:00
% =========================================================================
hold off;
end