Problem passing a function handle into icare
3 views (last 30 days)
Show older comments
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 Comment
dpb
on 18 Jan 2023
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.
Answers (1)
Adam Danz
on 19 Jan 2023
Edited: Adam Danz
on 23 Jan 2023
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 Comments
See Also
Categories
Find more on Matrix Computations 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!