Matlab CP 2 CEE 212
function [ g,grad_g ] = plane(z,params,type) % For a surface in 2D we input the z = [x;y] coordinates % and return the values of the function g and grad g where the % surface is defined as g(x,y)=0. The array params = [a,b,c,...] % holds the parameters needed to compute the function. The variable % 'type' defines the specific function. if type > 1; type = 1; end % default back to type 1 switch type case 1 % plane: g(x,y) = y - (a*x + b) a = params(1); b = params(2); x = z(1); y = z(2); g = y - (a*x + b); grad_g = [ -a; 1]; end end