How to convert a cell array to a symbolic array?
Afficher commentaires plus anciens
Hey guys,
I have a cell array of size x = cell(max(I(:)), numel(I), numel(I), numel(M), max(M(:))) that each element of this cell array is a matrix. I want to convert it to a symbolic array, and then pass this symbolic array to fmincon(). My objective function is a function of x and I want to min objfun w.r.t. x.
If x was a 2*2 matrix by using x = sym('x', [2 2]) I get
[ x1_1, x1_2]
[ x2_1, x2_2]
But how about the cell array? Any idea?
Thanks in advance.
5 commentaires
Susan
le 29 Avr 2019
gonzalo Mier
le 29 Avr 2019
I don't understand well your problem, but maybe you can use:
or C = { x1_1, x1_2; x2_1, x2_2}
or C = cell([2,2]) and then move x into C with a loop
Susan
le 30 Avr 2019
gonzalo Mier
le 30 Avr 2019
Modifié(e) : madhan ravi
le 30 Avr 2019
I have the feeling that you are not really sure about what you need. But either way, you can always move a symbolic matrix to cell like this:
C{3,3,3,10,2} = {};
C_mat_sym = sym('x', [3,3,3,10,2]);
for i = 1:length(C_mat_sym(:))
C{i} = C_mat_sym(i);
end
And if you need the actual value to hace double as result, use subs:
Susan
le 30 Avr 2019
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Conversion 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!