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 CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by