% span

clc;clf;clear all;

v_1 = [1,0,-1]; 
v_2 = [0,1,0];
p = [0,0,2];

rref([v_1' v_2']) % checking for linear independence

% vector containing weights
c_1 = -2:.25:2; 
c_2 = -2:.25:2;

% computing the span
for kk=1:length(c_1)
  for jj=1:length(c_2)
     y = c_1(kk)*v_1+c_2(jj)*v_2 + p;
     plot3(y(1),y(2),y(3),'ko');hold on; % plot the linear combination y
  end
end

% plotting the vector v_1 starting at p
quiver3(p(1),p(2),p(3),v_1(1),v_1(2),v_1(3));
xlim( [-4 4] );ylim( [-4 4] );zlim( [-4 4] );
hold on;

% plotting the vector p
quiver3(0,0,0,p(1),p(2),p(3));
hold on;

% plotting the vector v_2 starting at p
quiver3(p(1),p(2),p(3),v_2(1),v_2(2),v_2(3));
hold off;
