Where is my mistake on ga command in SIMULINK?

1 view (last 30 days)
Hi,
I am trying to use "ga" in SIMULINK, but i cannot perform it correctly.
Error message: Function handle cannot be used here.
How can i solve this problem?
Thanks,
function [uk, xk] = fcn(beta, w_z, yaw_angle, lat_pos,A_aug, B_aug, C_aug, yaw_angle_ref, Y_ref, uk_old, xk_old)
coder.extrinsic('ga');
...
J = (transpose(Rs - (F * Xf + phi * delta_Uk))) * Q * (Rs -(F * Xf + phi * delta_Uk)) + (transpose(delta_Uk)) * R_bar * delta_Uk;
nvars = 4;
lb = [];
ub = [];
Aeq = [];
beq = [];
P1 = [eye(p,p) zeros(p,p*(4 - 1))];
A = [T1; -T1;...
T1; -T1;...
];
b = [delta_uk_max; -delta_uk_min;...
uk_max - uk_old; -uk_min + uk_old;...
];
delta_Uk = ga(@J,nvars,A,b,Aeq,beq,lb,ub);

Answers (1)

Walter Roberson
Walter Roberson on 4 Oct 2021
J = (transpose(Rs - (F * Xf + phi * delta_Uk))) * Q * (Rs -(F * Xf + phi * delta_Uk)) + (transpose(delta_Uk)) * R_bar * delta_Uk;
That is not a function, it is a variable, probably a 2D array.
delta_Uk = ga(@J,nvars,A,b,Aeq,beq,lb,ub);
You are trying to take the handle to the 2D array J as if J were the name of a function.

Categories

Find more on Quadratic Programming and Cone Programming in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!