Ask Your Question

Matlab values as sage vector or matrix object ?

asked 2011-12-05 09:38:10 +0200

Cheatboy2 gravatar image

Hi all !

I tried Sage and I found that having a matlab interface is very useful, however I can't import matlab matrices as sage matrices (or numpy arrays) for further work into sage workspace.

For example :

a = matlab.linspace(1,10,20) # ok

a * 2 # ok

plot(a) # Attribute Error

vector(a) # Not Implemented Error

a.sage() # --> unable to parse output

Is there a way to avoid this problem ? Did I miss something in the documentation or does the MatlabElement type not support the same operations as the vector type does (excepted arithmetic operators) ?

Thanks !

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2011-12-06 11:13:44 +0200

Cheatboy2 gravatar image

It's ok !

It an error of my own.

Sage does provide a __matrix__ interface for MatlabElement (but not a __vector__ one so that explains my initial problem).

However it is based on string parsing so could be slow with large matrices. I gave a glance to Matlab binding package for the R programming language and it seems that the "fastest" way to communicate with matlab is to use the filesystem through mat files. Fortunately, it is easy to do in sage with scipy.sio.loadmat function and very fast.

Thanks for your answer Jason. Have a good day.

edit flag offensive delete link more

answered 2011-12-05 13:39:00 +0200

Jason Grout gravatar image

My guess is that the matlab interface is not very well-developed. I'd take a look at the error messages, but I don't have access to matlab.

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

1 follower


Asked: 2011-12-05 09:38:10 +0200

Seen: 447 times

Last updated: Dec 06 '11