File Exchange

image thumbnail

sym2str

version 1.1.0.0 (1.88 KB) by Martin Lawson
Converts symbolic variables to matlab strings using array opperations.

13 Downloads

Updated 03 Feb 2009

View Version History

View License

Converts symbolic variables to a Matlab equation string insuring that only array opps are used. Symbolic arrays are converted to linear Cell arrays of strings. This function is most often used to prepare symbolic answers for use with the "eval()" command. Also, converts Maple "atan" function to Matlab "atan2". Converts
Maple "array([[a,b],[c,d]])" notation to matlab "[a,b;c,d]" notation.

Note: eval() of a matrix only works if all the input variables have single values. i.e. vectors and arrays won't work.

Note2: eval() does not work on Cell arrays directly. Use "Cell_array{index}" to keep eval() happy

Cite As

Martin Lawson (2021). sym2str (https://www.mathworks.com/matlabcentral/fileexchange/19217-sym2str), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (7)

Mikhail Popkov

Very helpful, because in MatLab R2014 fprintf() can't understand sym().
So now I can run the code from R2017 at my R2014
Thanks!

Yurgil

Thank you very much!!

Georg Stillfried

Husam Aldahiyat

Great code, but the example is a bit weird.

MATLAB Release Compatibility
Created with R13
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired: campodir

Community Treasure Hunt

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

Start Hunting!