rsmenon / MATLink

Communicate with MATLAB from Mathematica
matlink.org
67 stars 14 forks source link

Importing arbitrary precision numbers into MatLAB (equivalent to vpa) #93

Closed valbert4 closed 7 years ago

valbert4 commented 7 years ago

Thank you for writing such a great program! I've been able to get many good results from it, but could use more precision. I think as of 2013, this was not supported. Is it now or are there plans to do so? Also... is it possible to pass a huge number as a string and then convert it to a big number in MatLAB? Thanks!

rsmenon commented 7 years ago

Glad that you liked MATLink! Answering your specific questions:

  1. Are there plans to add support for importing arbitrary precision numbers into MATLAB?

    No. VPA in MATLAB requires the symbolic toolbox and the APIs for this are not published/known and (to the best of my knowledge) cannot be accessed/controlled via the engine interface that we're using.

  2. Is it possible to pass a huge number as a string and then convert it to a big number in MATLAB?

    Yes, you can do this. Here's a small example:

    <<MATLink`
    OpenMATLAB[]
    MSet["x", "1234567890"]
    MEvaluate["y = evalin('base', 'x')"]
    (* 
        y =
    
            1.2346e+09
    *)

    Here x is a string in the MATLAB workspace but y is a float. You will lose some precision here in this example, but perhaps you can use the symbolic toolbox and vpa to convert that string into an arbitrary precision number? I can't help you much with that though since I don't have access to the toolbox.