function plotSphere(dim)
% plotSphere plottet die Einheitssphäre in 2d oder 3d

if ishold
	holdstatus = 1;
else 
	holdstatus = 0;
end

hold on


if dim == 2
	x = linspace(-1,1,100);
	y = [sqrt(1-x.^2); -sqrt(1-x.^2)];
	plot(x,y,'k-');
end

if dim == 3
	n = 20;
	
	x = linspace(-1.1, 1.1, n);
	y = linspace(-1.1, 1.1, n);
	z = linspace(-1.1, 1.1, n);
	[X,Y,Z] = meshgrid(x,y,z);
	data = sqrt(X.^2 + Y.^2 + Z.^2);
	cdata = smooth3(rand(size(data)),'box',7);
	p = patch(isosurface(X,Y,Z,data,1));
	isonormals(X,Y,Z,data,p)
	isocolors(X,Y,Z,cdata,p)
	p.FaceColor = 'k';
	p.FaceAlpha = 0.1;
	p.EdgeColor = 'none';
	view(150,30)
	daspect([1 1 1])
	axis tight
	camlight
	lighting gouraud
end

if holdstatus == 0
	hold off
end
