How to convert a sym array into a string array?

9 views (last 30 days)
I have very long arrays of symbolic variables which I need to convert to cell arrays of strings: For example, turning this:
syms x y u
q = [x y u]
into this:
qs = {'x' 'y' 'u'}
something like num2string() but with syms? I'd appreciate any help, thanks.

Accepted Answer

Walter Roberson
Walter Roberson on 23 Jul 2017
qc = arrayfun(@char, q, 'uniform', 0);
  4 Comments
Chris J
Chris J on 2 Jun 2021
Edited: Chris J on 2 Jun 2021
then string1 = cell2mat(qc)
Walter Roberson
Walter Roberson on 2 Jun 2021
syms x y u
q = [x y u]
q = 
cellstr(string(q))
ans = 1×3 cell array
{'x'} {'y'} {'u'}

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!