Where is my mistake on ga command in SIMULINK?

1 次查看(过去 30 天)
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);

回答(1 个)

Walter Roberson
Walter Roberson 2021-10-4
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.

类别

Help CenterFile Exchange 中查找有关 Quadratic Programming and Cone Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by