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
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!