⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 goalfun.m

📁 数字通信第四版原书的例程
💻 M
字号:
function [lambda,GS]=goalfun(V,neqcstr,evalstr1,evalstr2,WEIGHT,GOAL,x,P1,P2,P3,P4,P5,P6,P7,P8,P9,P10);
%GOALFUN Utility function to translate goal-attainment problem.
%
%	Intermediate function used to translate goal attainment
%	problem into constrained optimization problem.
%	Used by ATTGOAL and CONSTR. See also, GOALGRA.

%	Copyright (c) 1990 by the MathWorks, Inc.
%	Andy Grace 7-9-90.

g=[]; f=[];  % Tell parser that f and g are variables.
nx=length(V)-1;
x(:)=V(1:nx);
lambda=V(nx+1);
eval(evalstr1)
ncstr=length(WEIGHT);

GS = zeros(ncstr,1);
for i=1:ncstr
     if WEIGHT(i)~=0
       diff=f(i)-GOAL(i);
       GS(i)=sign(real(diff))*norm(diff)/WEIGHT(i)-lambda;
       if i<=neqcstr, GS(i+ncstr)=-GS(i)-2*lambda; end
      else
       GS(i)=f(i)-GOAL(i);
       if i<=neqcstr, GS(i+ncstr)=-GS(i)-1e-10; end
     end
end
GS=[GS;g(:)]; 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -