type Fish.txt				% type external file contents
fish=dlmread('Fish.txt');		% read in tabular data
size(fish)
fish
plot(fish(:,1),fish(:,2),'*')		% draw all the points;
s=find(fish(:,3)<0);			% find indices of all salmon samples
b=find(fish(:,3)>0);			% find indices of all seabass samples
plot(fish(s,1),fish(s,2),'*')		% draw the salmon
hold on;				% temporarily freeze current plot
plot(fish(b,1),fish(b,2),'r*')		% draw the seabass
hold off
ishold					% is plot frozen?
grid

fs=fish;				% make copy of sample data with . . .
fs(:,3)=1				% . . . extra constant entry for bias

w=[1;1;-1000]				% choose a linear classifier
fs*w;ans'
w=[1;1;-800]				% choose a better linear classifier (better bias)

fs*w;ans'				% apply classifier to every sample point.

x2=[380,540];				% choose vertical coordinates for separating line for plot.
x1=-(w(2)*x2+w(3))/w(1)			% boundary points are where x'*w == 0
x2
hold on;plot(x1,x2);hold off
w=[1;1;-750]				% move boundary to the left (same slope)
x1=-(w(2)*x2+w(3))/w(1)			% . . . and redraw.
hold on;plot(x1,x2);hold off

