% This m file plots a plane and a cone in 3-Space x = -2 : 0.05 : 2; % x as a vector y = transpose(x); % y as a vector [X, Y] = meshgrid(x, y); % x and y as matricies %Zplane1 = 1 + X; %Zplane2 = 1 - 3 * X; %Zcone = (X .^ 2 + Y.^2) .^ (1/2); for i = 1 : length(x) for j = 1 : length(x) point = 1 + x(i); if ((point <= 2) & (point >= 0)) Zplane1(i, j) = point; else Zplane1(i, j) = NaN; end point = 1 - 3 * x(i); if ((point <= 2) & (point >= 0)) Zplane2(i, j) = point; else Zplane2(i, j) = NaN; end point = (x(i) ^ 2 + y(j)^2) ^ (1/2); if ((point <= 2) & (point >= 0)) Zcone(i, j) = point; else Zcone(i, j) = NaN; end end end surf(X, Y, Zcone); figure; surf( X, Y, Zplane1); figure; surf( X, Y, Zplane2);