represent symbolic toolbox as a string

1 回表示 (過去 30 日間)
Philosophaie
Philosophaie 2013 年 12 月 6 日
コメント済み: Walter Roberson 2013 年 12 月 11 日
I am using the symbolic toolbox in Array1. How do you represent it as a string?
syms r,theta,phi
x=r*cos(theta)*cos(phi)
y=r*sin(theta)*cos(phi)
z=r*sin(phi)
Array1=num2str([x y z])

回答 (1 件)

sixwwwwww
sixwwwwww 2013 年 12 月 6 日
try this:
syms r theta phi
x=r*cos(theta)*cos(phi)
y=r*sin(theta)*cos(phi)
z=r*sin(phi)
Array1 = char([x y z])
  5 件のコメント
sixwwwwww
sixwwwwww 2013 年 12 月 6 日
you can do it as follow:
syms r theta phi
x = r * cos(theta) * cos(phi);
y = r * sin(theta) * cos(phi);
z = r * sin(phi);
Array1 = {char(x), char(y), char(z)};
% Print string on command window
for i = 1:3
fprintf('String number %d is: %s\n', i, Array1{i})
end
Walter Roberson
Walter Roberson 2013 年 12 月 11 日
Change
Array2(n)=char(Array1(i,j,k,l))
to
Array2{n}=char(Array1(i,j,k,l))

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAssumptions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by