Ask Your Question
1

Matlab values as sage vector or matrix object ?

asked 13 years ago

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 !

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
2

answered 13 years ago

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.

Preview: (hide)
link
0

answered 13 years ago

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.

Preview: (hide)
link

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

Stats

Asked: 13 years ago

Seen: 615 times

Last updated: Dec 06 '11