

close all; clear all;

data = load('exam_scores.txt');
data = data'; %take transpose to make data into a 3x100 matrix
y = data(3,:); % labels
m = length(data(1,:)); %# of training examples
x = ones(3,m); x(2,:) = data(1,:); x(3,:) = data(2,:); %embed data into a matrix
x1 = x(2,:); x2 = x(3,:); % x1: exam1, x2: exam2
y_pos = find(y==1); % find indices where label = 1
y_neg = find(y==0); % ditto for 0

figure(1);
plot(x1(y_pos),x2(y_pos),'r+','LineWidth',2,'MarkerSize',7); hold on; 
plot(x1(y_neg),x2(y_neg),'bo','LineWidth',2,'MarkerSize',7); hold off;

xlabel('exam1 score')
ylabel('exam2 score')
title('scatter plot of scores')
legend('passed','not passed')

% you will need to uncomment this part and plot the decision boundary
% xx1 = ?; yy1 = ?; %point #1 on decision boundary line
% xx2 = ?; yy2 = ?; %point #2 on decision boundary line
%
% figure(2);
% plot(x1(y_pos),x2(y_pos),'r+','LineWidth',2,'MarkerSize',7); hold on; 
% plot(x1(y_neg),x2(y_neg),'bo','LineWidth',2,'MarkerSize',7); hold on;
% plot([xx1 yy1], [xx2 yy2],'b-'); hold off; hold off;