How to convert a cell array to a symbolic array?
Show older comments
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 Comments
Susan
on 29 Apr 2019
gonzalo Mier
on 29 Apr 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
on 30 Apr 2019
gonzalo Mier
on 30 Apr 2019
Edited: madhan ravi
on 30 Apr 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
on 30 Apr 2019
Accepted Answer
More Answers (0)
Categories
Find more on Conversion 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!