0
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
1 function plotData(X, y) |
5
|
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. |
0
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
5 |
5
|
6 ## Create New Figure |
|
7 figure; hold on; |
0
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
8 |
5
|
9 ## Find Indices of Positive and Negative Examples |
|
10 pos = find(y==1); neg = find(y == 0); |
|
11 ## Plot Examples |
|
12 plot (X(pos, 1), X(pos, 2), "k+","LineWidth", 2, |
|
13 "MarkerSize", 7); |
|
14 plot (X(neg, 1), X(neg, 2), "ko", "MarkerFaceColor", |
|
15 "y", "MarkerSize", 7); |
0
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
16 |
5
|
17 hold off; |
0
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
diff
changeset
|
18 |
5
|
19 endfunction |