【发布时间】:2019-03-20 11:40:36
【问题描述】:
我试图理解多变量目标优化,我需要优化复杂的函数,但首先,我需要优化以下函数:
function ap_phase = objecfun(tau)
f = 1000; %Frequency
w = 2*pi*f; %Angular Frequency
trans_func = @(taux) (1-1i*w*taux)./(1+1i*w*taux); %Transfer function
trans_zero = trans_func(tau(1)); %Transfer function evaluated with the first variable
trans_quad = trans_func(tau(2)); %Transfer function evaluated with the second variable
ap_phase = rad2deg(phase(trans_zero)-phase(trans_quad)); %Phase difference
end
函数 objecfun 将一个长度为 2 的向量作为输入,计算 2 个传递函数,然后减去传递函数的相位。
我的目标是相位应该在 90° 左右
我用来优化的脚本如下
tau0 = [2E-5, 1E-3]; %Initial Value for tau(1) and tau(2)
lb = [1E-7, 1E-7]; %Lower bound for tau(1) and tau(2)
ub = [1E-2, 1E-2]; %Upper bound for tau(1) and tau(2)
goal = 90; %Optimization goal
weight = 1; %Weight
[x,fval] = fgoalattain(@objecfun,tau0,goal,weight,[],[],[],[],lb,ub)
优化器收敛,但我得到了一个错误的答案,我得到了
x =
0.0100 0.0000
fval =
-178.1044
错了,fval 应该接近 90°
我做错了什么?
【问题讨论】:
标签: matlab optimization