Problem passing a function handle into icare
4 次查看(过去 30 天)
显示 更早的评论
Hi,
I wrote the following code:
A_cen=@(x)[1 1 0 0;0 1 0 0;0 0 x(1) x(2);0 0 0 x(3)];
B_cen=@(x)[1 0;x(4) 0;0 x(5);0 x(6)];
Q1=ones(4,4);
R1=eye(2);
S1=zeros(4,2);
[X_1,F_1,~]=icare(A_cen,B_cen,Q1,R1,S1);
But I receive the following error:
Error using icare (line xx)
Input arguments to function include colon operator. To input the colon character, use ':' instead.
Error in fmincon_test5 (line yy)
[X_1,F_1,~]=icare(A_cen,B_cen,Q1,R1,S1);
I have tried finding an answer online regarding this problem, but it seems the solution is different for different circumstances. Could anybody tell exactly why this error is cropping up here? Thanks a lot beforehand.
1 个评论
dpb
2023-1-18
I don't have the TB but according to the doc icare doesn't accept function handles as inputs; it expects arrays. So evaluate the arrays before passing them.
回答(1 个)
Adam Danz
2023-1-19
编辑:Adam Danz
2023-1-23
A_cen and B_cen are functions that require 1 input. Fill in the 2 blanks below. The input to A_cen should have at least 3 elements and the input to B_cen should have at least 6 elements.
A_cen=@(x)[1 1 0 0;0 1 0 0;0 0 x(1) x(2);0 0 0 x(3)];
B_cen=@(x)[1 0;x(4) 0;0 x(5);0 x(6)];
Q1=ones(4,4);
R1=eye(2);
S1=zeros(4,2);
[X_1,F_1,~]=icare(A_cen(___),B_cen(___),Q1,R1,S1)
Perhaps these 2 anonymous functions are designed to receive the same variable that has at least 6 elements.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!