How to convert a sym array into a string array?

9 ビュー (過去 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