% Define a function to drive to zero. Input arg is the independent vars. function F = fit(x,f,Vc) % Can redefine independent vars for more meaningful names RF = x(1); CF = x(2); LF = x(3); % Return function evaluation at input vin, column vector. % Arrange so function = zero (ie. subtract eqn left side from right) Zl = j*2*pi*f*LF; Zc = 1./(j*2*pi*f*CF); F = Vc - (Zc ./ (RF + Zl + Zc)); % Separate real/imag columns so both are driven to zero F = [real(F), imag(F)]; endfunction