Search code examples
matlabsymbolic-math

define symbolic variables from a cell array of characters matlab symbolic math


I am very new to symbolic math Toolbox.

I am trying to create a symbolic math equations with the help of GUI. I am getting all the input variables from the user. I am either saving them as a cell array or normal matrix form.

Now how can I convert each variable as a symbolic variables. I have tried below codes but not working to my requirements.

cell2sym(cellArray)

also using for loop for each element

for i = 1:length(cellarray)
    variables{i} = sym(cellarray{i});
end

Solution

  • it works with eval function, thank you

    for i = 1: length(cellarray)
        eval(sprintf('syms(''%s'')',cellarray{i}))
    end