How to convert a sym array into a string array?

조회 수: 13 (최근 30일)
quoroy
quoroy 2017년 7월 23일
댓글: Walter Roberson 2021년 6월 2일
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.

채택된 답변

Walter Roberson
Walter Roberson 2017년 7월 23일
qc = arrayfun(@char, q, 'uniform', 0);
  댓글 수: 4
Chris J
Chris J 2021년 6월 2일
편집: Chris J 2021년 6월 2일
then string1 = cell2mat(qc)
Walter Roberson
Walter Roberson 2021년 6월 2일
syms x y u
q = [x y u]
q = 
cellstr(string(q))
ans = 1×3 cell array
{'x'} {'y'} {'u'}

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품

Community Treasure Hunt

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

Start Hunting!

Translated by