How do I output a MATLAB symbolic expression to a file?
9 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I would like to write a symbolic expression using the FPRINTF function.
Risposta accettata
MathWorks Support Team
il 27 Giu 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 Commenti
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!