MATLAB R2015a multivariable function optimization
3 次查看(过去 30 天)
显示 更早的评论
I am trying to minimize an objective function with two variables, using MATLAB R2015a. The objective function is:
function i3 = fob_2(kp,ti)
G_P = tf(0.2,[2 4 1]);
G_TT = tf(0.1,[0.5 1]);
G_TC = tf(kp*[1 1/ti],[1 0]);
G_CV = 50;
G_TA = 0.1;
G_direct = G_TC * G_CV * G_P;
G_loop = feedback (G_direct , G_TT);
G_SYS = G_TA * G_loop;
SP = 1;
[DT,time] = step(SP * G_SYS);
error = SP - DT;
i3 = trapz(time,error.^2);
I tried a few optimization functions, but none of them seem to work. I always get the error message: "**Not enough input arguments.**" at the fifth line of the function, which is
G_TC = tf(kp*[1 1/ti],[1 0]);
I tried the following functions, presented by the used syntax (at this point I don't care much about the starting point. I care more about getting an answer and correctly programming the optimization function):
y=fminimax(fob_2,[1,1])
y=fminsearch(fob_2,[1,1])
y=fminunc(fob_2,[1,1])
I am sure that the function is correctly programmed, because when I try to call it with two parameters, something like:
fob_2(2,5)
MATLAB returns the computed value.
So, the problem is on my end, but I don't see where am I mistaking. Can you help me?
Thank you in advance.
0 个评论
采纳的回答
Walter Roberson
2016-5-1
编辑:Walter Roberson
2016-5-1
fob_2v = @(kt) fob_2(kt(1), kt(2))
y=fminsearch(fob_2v,[1,1])
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Optimization Toolbox 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!