Problem passing a function handle into icare
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commento
dpb
il 18 Gen 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.
Risposte (1)
Adam Danz
il 19 Gen 2023
Modificato: Adam Danz
il 23 Gen 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 Commenti
Vedere anche
Categorie
Scopri di più su Linear Algebra in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!