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!