How to convert a cell array to a symbolic array?
Mostrar comentarios más antiguos
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 comentarios
Susan
el 29 de Abr. de 2019
gonzalo Mier
el 29 de Abr. de 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
el 30 de Abr. de 2019
gonzalo Mier
el 30 de Abr. de 2019
Editada: madhan ravi
el 30 de Abr. de 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
el 30 de Abr. de 2019
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Conversion en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!