File Exchange

image thumbnail

SymPy CAS in MATLAB

version 1.4 (2.49 KB) by

Enables using Python's SymPy CAS in MATLAB

3 Downloads

Updated

View License

This function utilizes Python's SymPy module to provide symbolic capabilities for those of us who do not have the Symbolic Toolbox or a version of Matlab with Python support at our disposal. The function passes strings to and from Python via the System command. Computation of the result is easily accomplished via the vectorize and inline functions.
Example:
result = symeval('integrate','"x^2+3x-4"','x');
y = vectorize(inline(result));
plot(y([1:100])

This can be slow since the Python interpreter is started and shutdown every time the function is called. However, successive calls are sped up due to OS caching.

Another option is to use the pymex module posted on this file exchange:
http://www.mathworks.com/matlabcentral/fileexchange/27255-pymex

The best way is to just call the library directly with a version of MATLAB that supports Python.

Comments and Ratings (3)

Jonathan Lister

The entry "Maxima Cas in Matlab" works better IMO.

Jonathan Lister

Try:

result = symeval('integrate','"(cos(x)/x) - (sin(x)/x^2)"','x')
f = vectorize(inline(result));
plot(f(1:.1:100))

Jonathan Lister

make sure the equation string that you pass in is enclosed within a double quotes as well as the single quote...

funstr = '"x^2 + 2*x + 1"'
result = symeval('factor',funstr)

Updates

1.4

Updated description and comments to reflect changes in MATLAB's capabilities.

1.4

Added image and changed title text...

1.3

updated title, description, and other requirements text

MATLAB Release
MATLAB 7.14 (R2012a)
Acknowledgements

Inspired by: MAXIMA CAS in MATLAB

Inspired: MAXIMA CAS in MATLAB

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today