How do I output a MATLAB symbolic expression to a file?

조회 수: 9 (최근 30일)
I would like to write a symbolic expression using the FPRINTF function.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2009년 6월 27일
The symbolic expression has to be first converted into a character array (string) using the CHAR function. The '%s' specification is then used in conjunction with the FPRINTF function.
For example, consider a symbolic variable 'x'.
x = sym('x');
class(x)
Before using 'x' directly with FPRINTF, it has to converted using the CHAR function:
x = char(x)
The FPRINTF function can now be used to output 'x', by using the '%s' specification:
fprintf('%s',x)
Note that in this instance, the results of FPRINTF appear in the MATLAB Command Prompt because no open file was specified to write to. For more information regarding this function, enter the following at the MATLAB Command Prompt:
doc fprintf

추가 답변 (0개)

제품


릴리스

R14SP2

Community Treasure Hunt

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

Start Hunting!

Translated by