How to convert a cell array to a symbolic array?
显示 更早的评论
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 个评论
Susan
2019-4-29
gonzalo Mier
2019-4-29
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
2019-4-30
gonzalo Mier
2019-4-30
编辑:madhan ravi
2019-4-30
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
2019-4-30
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!