-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplotTrainingData.m
34 lines (30 loc) · 1017 Bytes
/
plotTrainingData.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
%% plotTrainingData(X, y, size)
% _This function plots the mat file given in the assignment._
%
% Inputs:
%
% # X: The Data Matrix
% # y: The labels for Graph
% # Optional Input: size (number) input the size of scatter points in pixls by using this option input. Default value used is 55.
%
% Output: A graph with blue and red scatters
function [graphPlot] = plotTrainingData(X, y, size)
defaultPixelSize = 55;
y = logical(y);
yInverse = ~y;
red = X(y,:);
blue = X(yInverse,:);
if (exist('size', 'var'))
graphPlot = scatter(red(:,[1]), red(:,[2]), size, [1 0 0], 'filled');
hold on;
scatter(blue(:,[1]), blue(:,[2]), size, [0 0 1], 'filled');
else
graphPlot = scatter(red(:,[1]), red(:,[2]), defaultPixelSize, [1 0 0], 'filled');
hold on;
scatter(blue(:,[1]), blue(:,[2]), defaultPixelSize, [0 0 1], 'filled');
end
title('Training Data Scatter-Plot');
xlabel('X-Axis')
ylabel('Y-Axis')
return
end