MINIMIZE symbolic function P
Afficher commentaires plus anciens
X(t) = sym('x',[6 2])
syms t
syms X(t) t t0 tf N
a = diff(X(t),t)
b=a'
f=b*a
int( f,t, t0,tf)
P = symsum(f,t,0,N)
I need to minimize this symbolic (matrix) function P
Constraints:-
1.) P ∈ {0,1}
2.)P'*P=eye(M)
3.) t ∈ [t0, tf ]
4.) N=6
Réponses (1)
Walter Roberson
le 18 Fév 2019
Modifié(e) : Walter Roberson
le 18 Fév 2019
syms t t0 tf
N = 6;
M = 2;
x = sym('x',[6 M]);
X(t) = str2sym(string(x) + "(t)");
a = diff(X(t), t);
b = a';
f = b*a;
f_int = int(f, t, t0, tf); %I do not know what this is for
temp = arrayfun(@(idx) subs(f(idx),t,1:N), 1:M.^2, 'uniform', 0);
P = reshape(sum(cat(1,temp{:}),2), M, M);
f is 2 x 2 because you are multiplying (6x2)' * (6x2) so (2x6) * (6x2) so 2x2 result.
You then symsum() the 2 x 2 over 6 different times (and it is pretty strange to choose integer times 1 through 6 when you have a constraint about t ∈ [t0, tf ] ). You would be getting a 2 x 2 result.
You then talk about P'*P, which is going to be (2x2).' * (2x2) which is (2x2)*(2x2) which is going to give a 2x2 result. That cannot possibly be eye(6)
So P will be either 2 x 2 (following your mathematics) or something x 6 (following your eye(6)). Either way, it is multi-valued, and then one has to ask what it means to minimize a multi-valued function.
4 commentaires
madhan ravi
le 18 Fév 2019
Modifié(e) : madhan ravi
le 18 Fév 2019
sir Walter in your code you mentioned ttt{:} I guess that’s a typo for temp{:}
Walter Roberson
le 18 Fév 2019
Ah, you are right, I was using ttt in my testing and changed to temp for posting.
Vanshika Singh
le 18 Fév 2019
Modifié(e) : Vanshika Singh
le 18 Fév 2019
Vanshika Singh
le 18 Fév 2019
Catégories
En savoir plus sur Symbolic Math Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

