MATLAB: Cell symbolic matrix into simple symbolic matrix

cellduplicate post requiring merging

Hello all,
I am having a cell of 3d symbolic object matrix, but I need to convert this matrix into simple symbolic matrix.
I tried using 'cell2mat' function but it is not helping as this function doesn't help when cell contains symbolic objects.
I need to convert into simple matrix as, I need to perform some multiplication operation on simple matrix, which is not possible if it is in cell form.
Can anyone help me, in this regard.

Best Answer

  • >> x = sym(0);
    A(1:4,1,1:4) = [ {x} {x} {x} {x};
    {x} {x} {x} {x};
    {x} {x} {x} {x};
    {x} {x} {x} {x} ]
    A(:,:,1) =
    [1x1 sym]
    [1x1 sym]
    [1x1 sym]
    [1x1 sym]
    A(:,:,2) =
    [1x1 sym]
    [1x1 sym]
    [1x1 sym]
    [1x1 sym]
    A(:,:,3) =
    [1x1 sym]
    [1x1 sym]
    [1x1 sym]
    [1x1 sym]
    A(:,:,4) =
    [1x1 sym]
    [1x1 sym]
    [1x1 sym]
    [1x1 sym]
    >> A1 = squeeze(A)
    A1 =
    [1x1 sym] [1x1 sym] [1x1 sym] [1x1 sym]
    [1x1 sym] [1x1 sym] [1x1 sym] [1x1 sym]
    [1x1 sym] [1x1 sym] [1x1 sym] [1x1 sym]
    [1x1 sym] [1x1 sym] [1x1 sym] [1x1 sym]
    >> A2 = reshape([A{:}],size(A1))
    A2 =
    [ 0, 0, 0, 0]
    [ 0, 0, 0, 0]
    [ 0, 0, 0, 0]
    [ 0, 0, 0, 0]
    >>