mysig = 25;
myncl = 10;
[g1 k1 cdat1] = gmmnl2(cpoint, myncl, mysig);
[g2 k2 cdat2] = gmmnl2(cstop, myncl, mysig);
[g3 k3 cdat3] = gmmnl2(cwave, myncl, mysig);

right = 0;
tot = 0;
ap = [];
bp = [];
cp = [];
dp = [];
ep = [];
fp = [];
gp = [];
hp = [];
ip = [];
votes = zeros(10,1);
votep = zeros(10,1);
votew = zeros(10,1);
votex = zeros(10,1);
vssurf = zeros(12,100);
vpsurf = zeros(12,100);
vwsurf = zeros(12,100);
vsct = 1;
vpct = 1;
vwct = 1;
op = 1;
ow = 1;
os = 1;
pct = ones(10,1);
sct = ones(10,1);
wct = ones(10,1);
for x = 1:550
	ap(x) = nldist(cpoint(x, :), cdat1, myncl, mysig, g1, k1)/myncl;
	cp(x) = nldist(cpoint(x, :), cdat2, myncl, mysig, g2, k2)/myncl;
	hp(x) = nldist(cpoint(x, :), cdat3, myncl, mysig, g3, k3)/myncl;

	bp(x) = nldist(cstop(x, :), cdat1, myncl, mysig, g1, k1)/myncl;
	dp(x) = nldist(cstop(x, :), cdat2, myncl, mysig, g2, k2)/myncl;
	gp(x) = nldist(cstop(x, :), cdat3, myncl, mysig, g3, k3)/myncl;

	ep(x) = nldist(cwave(x, :), cdat1, myncl, mysig, g1, k1)/myncl;
	fp(x) = nldist(cwave(x, :), cdat2, myncl, mysig, g2, k2)/myncl;
	ip(x) = nldist(cwave(x, :), cdat3, myncl, mysig, g3, k3)/myncl;

	if(mod(x, 25) == 0)
		figure(4)
		hold off;
		plot(votes./sct, 'red-');
		hold on;
		plot(votep./pct, 'blue-');
		plot(votew./wct, 'green-');
		plot(votex./wct, 'yellow-');
				

		figure(1);
		hold off;
		plot(ap, 'red-');
		hold on;
		plot(cp, 'blue-');
		plot(hp, 'green-');
		plot([0 x], [0 0], 'black-');
	
		figure(2);
		hold off;
		plot(bp, 'red-');
		hold on;
		plot(dp, 'blue-');
		plot(gp, 'green-');
		plot([0 x], [0 0], 'black-');

		figure(3);
		hold off;
		plot(ep, 'red-');
		hold on;
		plot(fp, 'blue-');
		plot(ip, 'green-');
		plot([0 x], [0 0], 'black-');
		figure(4);
	end

%	ap(x) = nldist(cdat1(x, :), cdat1, myncl, mysig, g1, k1)/myncl;
%	bp(x) = nldist(cdat2(x, :), cdat1, myncl, mysig, g1, k1)/myncl;
%	cp(x) = nldist(cdat1(x, :), cdat2, myncl, mysig, g2, k2)/myncl;
%	dp(x) = nldist(cdat2(x, :), cdat2, myncl, mysig, g2, k2)/myncl;
	tot = tot+1;
	pct(point(x,1))=pct(point(x,1))+1;
	sct(stop(x,1))=sct(stop(x,1))+1;
	wct(wave(x,1)+1)=wct(wave(x,1)+1)+1;
	if(point(x,1) ~= op)
		vpct = 1;
		op = point(x,1);
	end
	if(wave(x,1) ~= ow)
		vwct = 1;
		ow = wave(x,1);
	end
	if(stop(x,1) ~= os)
		vsct = 1;
		os = stop(x,1);
	end
	if((ap(x) > cp(x)) & (ap(x) > hp(x)))
		right = right+1;
		votep(point(x, 1)) = votep(point(x, 1)) +1;
		vpsurf(point(x,1),vpct) = 1;
	end
	if((dp(x) > bp(x)) & (dp(x) >gp(x)))
		right = right+1;
		votes(stop(x,1)) = votes(stop(x,1))+1;
		vssurf(stop(x,1),vsct) = 1;
	end
	if((ip(x) > fp(x)) & (ip(x) > ep(x)))
		right = right +1;
		votew(wave(x,1)+1) = votew(wave(x,1)+1)+1;
		vwsurf(wave(x,1)+1,vwct) = 1;
	elseif((ep(x) > fp(x)) & (ep(x) > ip(x)))
		votex(wave(x,1)+1) = votex(wave(x,1)+1)+1;
	end
	vpct = vpct+1;
	vsct = vsct+1;
	vwct = vwct+1;
%	ap(x) = nldist(cpoint(x, :), cdat1, myncl, mysig, g1, k1)/myncl;
%	bp(x) = nldist(cstop(x, :), cdat1, myncl, mysig, g1, k1)/myncl;
%	cp(x) = nldist(cpoint(x, :), cdat2, myncl, mysig, g2, k2)/myncl;
%	dp(x) = nldist(cstop(x, :), cdat2, myncl, mysig, g2, k2)/myncl;
	[tot right./(tot*3) right ]
end
right./(tot*3)