MATLAB R2015a multivariable function optimization

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.

 Réponse acceptée

Walter Roberson
Walter Roberson le 1 Mai 2016
Modifié(e) : Walter Roberson le 1 Mai 2016
fob_2v = @(kt) fob_2(kt(1), kt(2))
y=fminsearch(fob_2v,[1,1])

3 commentaires

Bogdan
Bogdan le 1 Mai 2016
It worked! Thank you very much!
Can you tell me, please, how did you think this solution? :)
Lots of experience ;-) This kind of solution gets used a lot.
Bogdan
Bogdan le 1 Mai 2016
I understand. Thank you, one more time :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by