% function [K] = area2P (A0,A1,A2,Kmax); % % Function araa2P calculates parameter of the P (proportional) controller: % % u = K*e % % from the measured areas of the process A0 to A2 (A0 is the process steady-state gain). % The parameter Kmax represents the highest allowed open-loop gain K*A0 function [K] = area2P (A0,A1,A2,Kmax); Num = 2*A0*A2 - A1*A1; % Numerator Den = 2*A0*(A1*A1-A0*A2); % Denominator if (Num == 0) K = 0; elseif (Den == 0) if (A0 ~= 0) K = Kmax/A0; else K = Kmax; end; else K = Num/Den; end; Tmp = K*A0; % Nominal gain if (Tmp > Kmax) | (Tmp < 0) K = Kmax/A0; end;