% 3D plott av en ellipsoide
x=linspace(-5,3,20);
y=linspace(-5,3,20);
[X,Y]=meshgrid(x,y);
mesh(X,Y,(X+1).^2/1.5^2 + (Y+1).^2/3^2)
axis equal

% 2D Contour plott av ellipsoiden
figure()
contour(X,Y,(X+1).^2/1.5^2 + (Y+1).^2/3^2)
axis equal

% 3D contour plott av ellipsoiden
figure()
contour3(X,Y,(X+1).^2/1.5^2 + (Y+1).^2/3^2)
axis equal

% 3D plott av en paraboloide
figure()
theta = linspace(0,2*pi,50);
r = linspace(0,2,50);
[rv,thetav] = meshgrid(r,theta);
surf(rv.*cos(thetav),rv.*sin(thetav), rv.^2)
axis equal

% Halvkule med radius 2
figure()
phi = linspace(0,pi/2,50);
theta = linspace(0,2*pi,50);
[phiv,thetav] = meshgrid(phi,theta);
surf(2*cos(thetav).*sin(phiv),2*sin(thetav).*sin(phiv), 2*cos(phiv))
axis equal

% 2D vektorfelt plott
figure()
x=linspace(-1,1,10);
y=x;
[X,Y]=meshgrid(x,y);
quiver(X,Y,-X./(X.^2+Y.^2).^(3/2), -Y./(X.^2+Y.^2).^(3/2))

% 3D vektorfelt plott
figure()
x=linspace(-1,1,10);
y=x; z= x;
[X,Y,Z]=meshgrid(x,y,z);
quiver3(X,Y,Z,-X./(X.^2+Y.^2+Z.^2).^(3/2), -Y./(X.^2+Y.^2+Z.^2).^(3/2), -Z./(X.^2+Y.^2+Z.^2).^(3/2))

% 2D strømlinjeplott
figure()
x=linspace(-1,1,10);
y=x;
[X,Y]=meshgrid(x,y);
streamline(X,Y,-X./(X.^2+Y.^2).^(3/2), -Y./(X.^2+Y.^2).^(3/2),[0 1 1],[1 0 1])

% 3D plott av en torus
figure()
theta=linspace(0,2*pi,100);
phi=linspace(0,2*pi,100);
[thetav,phiv]=meshgrid(theta,phi);
surf( (3+cos(phiv)).*cos(thetav), (3+cos(phiv)).*sin(thetav), sin(phiv))
axis equal