%first copy the file plane.m into your matlab
working directory,
%otherwise, matlab won't know how to calculate the function
%plane(x,y) = x - 2y + 3
%graph the surface of the plane over the rectangular domain
%x in [-4,4] and y in [-4,4]
[x,y]=meshgrid([-4:.01:4], [-4:.01:4]);
fig1 = mesh(x,y,plane(x,y));
hold on;
axis([-4, 4, -4, 4, -10, 15]);
view([127.5, 10]);
%this rotates our view so that the axis so x and y are pointing
%more or less in the usual directions :)
%plot some contour lines in the x-y plane (at z = -10) so you can
%see them beneath the plane
%remember the level curves are lines of the form y = 1/2(x - (c-3))
%we plot the contours for c = -4, -2, 0, 2, 4, 6, 8, 10
c = -4;
x1 = [max(-11+c, -4):.01:min(4, 5+c)];
%making sure the line stays in the domain [-4,4]x[-4,4]!
plot3(x1, .5.*(x1-(c-3)), -10.*ones(size(x1)), '-ok', 'LineWidth', 2);
c = -2;
x1 = [max(-11+c, -4):.01:min(4, 5+c)];
plot3(x1, .5.*(x1-(c-3)), -10.*ones(size(x1)), '-ob', 'LineWidth', 2);
c = 0;
x1 = [max(-11+c, -4):.01:min(4, 5+c)];
plot3(x1, .5.*(x1-(c-3)), -10.*ones(size(x1)), '-or', 'LineWidth', 2);
c = 2;
x1 = [max(-11+c, -4):.01:min(4, 5+c)];
plot3(x1, .5.*(x1-(c-3)), -10.*ones(size(x1)), '-ok', 'LineWidth', 2);
c = 4;
x1 = [max(-11+c, -4):.01:min(4, 5+c)];
plot3(x1, .5.*(x1-(c-3)), -10.*ones(size(x1)), '-ob', 'LineWidth', 2);
c = 6;
x1 = [max(-11+c, -4):.01:min(4, 5+c)];
plot3(x1, .5.*(x1-(c-3)), -10.*ones(size(x1)), '-or', 'LineWidth', 2);
c = 8;
x1 = [max(-11+c, -4):.01:min(4, 5+c)];
plot3(x1, .5.*(x1-(c-3)), -10.*ones(size(x1)), '-ok', 'LineWidth', 2);
c = 10;
x1 = [max(-11+c, -4):.01:min(4, 5+c)];
plot3(x1, .5.*(x1-(c-3)), -10.*ones(size(x1)), '-ob', 'LineWidth', 2);
%plots the contour lines, moved up to the right heights z = c
%so that they lie on the surface of the plane!
c = -4;
x1 = [max(-11+c, -4):.01:min(4, 5+c)];
plot3(x1, .5.*(x1-(c-3)), c.*ones(size(x1)), '-ok', 'LineWidth', 2);
c = -2;
x1 = [max(-11+c, -4):.01:min(4, 5+c)];
plot3(x1, .5.*(x1-(c-3)), c.*ones(size(x1)), '-ob', 'LineWidth', 2);
c = 0;
x1 = [max(-11+c, -4):.01:min(4, 5+c)];
plot3(x1, .5.*(x1-(c-3)), c.*ones(size(x1)), '-or', 'LineWidth', 2);
c = 2;
x1 = [max(-11+c, -4):.01:min(4, 5+c)];
plot3(x1, .5.*(x1-(c-3)), c.*ones(size(x1)), '-ok', 'LineWidth', 2);
c = 4;
x1 = [max(-11+c, -4):.01:min(4, 5+c)];
plot3(x1, .5.*(x1-(c-3)), c.*ones(size(x1)), '-ob', 'LineWidth', 2);
c = 6;
x1 = [max(-11+c, -4):.01:min(4, 5+c)];
plot3(x1, .5.*(x1-(c-3)), c.*ones(size(x1)), '-or', 'LineWidth', 2);
c = 8;
x1 = [max(-11+c, -4):.01:min(4, 5+c)];
plot3(x1, .5.*(x1-(c-3)), c.*ones(size(x1)), '-ok', 'LineWidth', 2);
c = 10;
x1 = [max(-11+c, -4):.01:min(4, 5+c)];
plot3(x1, .5.*(x1-(c-3)), c.*ones(size(x1)), '-ob', 'LineWidth', 2);