Ask Your Question

Is it possible to use Matlab Code to control SAGE?

asked 2010-10-25 13:34:59 +0100

Neuneck gravatar image


i'm joining a course at University that requires me to use MatLab and although there is a Campus License available, I'd prefer to use an open source program. However, I'm required to turn in the exercise as compileable MatLab code. Browsing the web for alternatives, I found Sage and now I wonder if I can use "proper" MatLab code in Sage.

Thanks for the time you take to read and answer my question!


edit retag flag offensive close merge delete



ccanonc gravatar imageccanonc ( 2010-10-25 13:46:31 +0100 )edit

2 Answers

Sort by » oldest newest most voted

answered 2010-10-25 17:04:34 +0100

There is also an Open-Source MATLAB®-to-Python® Compiler, which you can use to run your matlab code in Python. It would be great if this was better integrated with the notebook so that you could have "%ompc" cells that were compiled to python behind the scenes and executed, much like what happens with "%cython" or "%fortran" now.

edit flag offensive delete link more

answered 2010-10-25 14:57:50 +0100

niles gravatar image

I believe this is not possible. Sage can accept pure MatLab code, or code from a number of other systems, but only when it's acting as a console for those systems -- see the interfaces section of the manual -- the purpose of Sage interfaces is rather the opposite of what you're looking for: interfaces allow you to use Sage syntax to run other programs. And it works by calling those programs from Sage, so you have to install them and use them. As I understand it, this is useful really only for those who want to use several different programs side-by-side. If you will be using only a single program, it makes more sense to interact with it directly if you can.

If the course has a small number of people in it and your instructor is willing to be flexible, you might try pointing out that public servers like would allow them to evaluate the functionality of Sage code without having to go through the (easy) process of installing Sage. But if homework grading is going to be automated, your instructor probably isn't willing to go through the trouble of adding support for Sage. And you're both going to be unhappy if, midway through the term, you find that Sage doesn't have support for some topics in the course.

Whatever ends up happening, bear in mind that you will have more opportunities to use open source software in the future, even if you don't have that choice as a student.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2010-10-25 13:34:59 +0100

Seen: 1,885 times

Last updated: Oct 25 '10