How do I output a MATLAB symbolic expression to a file?
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I would like to write a symbolic expression using the FPRINTF function.
Réponse acceptée
MathWorks Support Team
le 27 Juin 2009
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 commentaires
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!