Calling Python from Matlab

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Carl

    #1

    Calling Python from Matlab

    I am desperately looking for a way to call Python from Matlab. I have become
    used to Python's rich syntax and large number of libraries, and feel
    ridiculously clumsy being stuck with Matlab's rather restricted facilities
    for doing other things than standard mathematical work.

    Does anyone know of good techniques (or readily available software) for
    achieving a cross-language support between Python and Matlab?

    Carl
  • Daniel Nogradi

    #2
    Re: Calling Python from Matlab

    > I am desperately looking for a way to call Python from Matlab. I have become[color=blue]
    > used to Python's rich syntax and large number of libraries, and feel
    > ridiculously clumsy being stuck with Matlab's rather restricted facilities
    > for doing other things than standard mathematical work.
    >
    > Does anyone know of good techniques (or readily available software) for
    > achieving a cross-language support between Python and Matlab?
    >
    > Carl[/color]

    Perhaps you will find this useful:


    Comment

    • Michael Tobis

      #3
      Re: Calling Python from Matlab

      I'm afraid I can't be very helpful to you, but you could be most
      helpful to some of us.

      Can you elaborate on what specifically you found difficult? In some
      circles Python is regarded as a direct competitor to Matlab. Your
      preference for Python for "other things than standard mathematical
      work" in a scientific or engineering context could be most useful if
      you have some real-world examples.

      Also, can you elaborate on what (if anything) it is about Matlab that
      you feel you can't replicate in Python? Are you aware of matplotlib and
      numpy?

      thanks
      mt

      Comment

      • Kelvie Wong

        #4
        Re: Calling Python from Matlab

        I have a suspicion it is the collaborative effort that is the problem
        here -- I try to use Python whenever possible for
        engineering/numerical analysis, but the established industry standard
        (for most disciplines of engineering) is still MATLAB.

        Although Python is arguably better in most respects, especially being
        a full-blown programming language (and modules such as SciPy and NumPy
        are just great), but it's hard to expect your co-workers to be using
        Python for analysis also.

        On 15 Apr 2006 16:00:08 -0700, Michael Tobis <mtobis@gmail.c om> wrote:[color=blue]
        > I'm afraid I can't be very helpful to you, but you could be most
        > helpful to some of us.
        >
        > Can you elaborate on what specifically you found difficult? In some
        > circles Python is regarded as a direct competitor to Matlab. Your
        > preference for Python for "other things than standard mathematical
        > work" in a scientific or engineering context could be most useful if
        > you have some real-world examples.
        >
        > Also, can you elaborate on what (if anything) it is about Matlab that
        > you feel you can't replicate in Python? Are you aware of matplotlib and
        > numpy?
        >
        > thanks
        > mt
        >
        > --
        > http://mail.python.org/mailman/listinfo/python-list
        >[/color]

        Comment

        • Carl

          #5
          Re: Calling Python from Matlab

          Kelvie Wong wrote:
          [color=blue]
          > I have a suspicion it is the collaborative effort that is the problem
          > here -- I try to use Python whenever possible for
          > engineering/numerical analysis, but the established industry standard
          > (for most disciplines of engineering) is still MATLAB.
          >
          > Although Python is arguably better in most respects, especially being
          > a full-blown programming language (and modules such as SciPy and NumPy
          > are just great), but it's hard to expect your co-workers to be using
          > Python for analysis also.
          >
          > On 15 Apr 2006 16:00:08 -0700, Michael Tobis <mtobis@gmail.c om> wrote:[color=green]
          >> I'm afraid I can't be very helpful to you, but you could be most
          >> helpful to some of us.
          >>
          >> Can you elaborate on what specifically you found difficult? In some
          >> circles Python is regarded as a direct competitor to Matlab. Your
          >> preference for Python for "other things than standard mathematical
          >> work" in a scientific or engineering context could be most useful if
          >> you have some real-world examples.
          >>
          >> Also, can you elaborate on what (if anything) it is about Matlab that
          >> you feel you can't replicate in Python? Are you aware of matplotlib and
          >> numpy?
          >>
          >> thanks
          >> mt
          >>
          >> --
          >> http://mail.python.org/mailman/listinfo/python-list
          >>[/color][/color]
          This is exactly my problem!

          I have to use Matlab at work because it is the language my fellow co-workers
          use. At my previous work we used Python as our language of choice. I never
          had had to use Matlab because Numeric, numarray, SciPy, etc were already
          there. These libraries worked beautifully with Python!

          My major problem with Matlab is not the language; it is a quite nice
          language, comparable to Python and R. The problem is the lack of libraries
          for doing things that are not basic mathematical stuff, such as reading
          text from files, handling strings, pickling, etc. When you are used to
          Python's large number of high-quality modules you feel disadvantaged being
          confined to using only Matlab.

          I have learnt that Matlab provides a facility for executing Perl commands
          and running Perl scripts, but I have not used it yet. It would have been
          nice to have the possibility of mixing Matlab and Python code, by using
          inlining, for example!

          One option could be to use Perl to call Python from within Matlab.

          Carl

          Comment

          • AgenteSegreto

            #6
            Re: Calling Python from Matlab

            I've been a Matlab user for years and have recently started using
            Python with matplotlib and NumPy for most of my work. The only thing I
            found that is still lacking is a 3D capability in matplotlib. I was
            trying to visualize a hill climbing algorithm and I couldn't find
            anything comparable to Matlab's 'surface', 'mesh', or 'plot3'. I think
            VTK would have done the trick but there's only so much time in the
            day...

            Comment

            • Lawrence D'Oliveiro

              #7
              Re: Calling Python from Matlab

              In article <2Po0g.9446$zc1 .6404@amstwist0 0>,
              Carl <phleum_nospam@ chello.se> wrote:
              [color=blue]
              >My major problem with Matlab is not the language; it is a quite nice
              >language, comparable to Python and R.[/color]

              Having done a bunch of MATLAB GUI programming for a client a few years
              ago, I would not agree that MATLAB is a "nice" language at all. The
              basic matrix stuff is fine, but all the structure stuff had a definite
              feling of being tacked on. The GUI stuff in particular was very fiddly
              to do.

              Comment

              • John Hunter

                #8
                Re: Calling Python from Matlab

                >>>>> "AgenteSegr eto" == AgenteSegreto <nashborges@gma il.com> writes:

                AgenteSegreto> I've been a Matlab user for years and have recently
                AgenteSegreto> started using Python with matplotlib and NumPy for
                AgenteSegreto> most of my work. The only thing I found that is
                AgenteSegreto> still lacking is a 3D capability in matplotlib. I

                There is some progress being made on this front -- in svn are a
                collection of classes for basic 3d plots (plot3, mesh, surf) but the
                interface to these is still under development. We hope they will be
                included in the next major release 0.88.

                You can see some examples here:



                Also, there is a master's student who will be working on extending mpl
                3d capabilities as part of her master's project, so expect some basic
                functionality in the near future.

                We certainly don't aim to compete with VTK or other full-blown 3D
                solutions like Mayavi

                Home page for MayaVi, a free, cross platform, easy to use scientific data visualizer. It provides a GUI to ease the visualization process, is written in Python and uses the Visualization Toolkit (VTK) for the graphics.




                but most agree it would be nice to have some support for basic 3D
                plotting in matplotlib.

                JDH

                Comment

                • Alexander Schmolck

                  #9
                  Re: Calling Python from Matlab

                  "Daniel Nogradi" <nogradi@gmail. com> writes:
                  [color=blue][color=green]
                  > > I am desperately looking for a way to call Python from Matlab. I have become
                  > > used to Python's rich syntax and large number of libraries, and feel
                  > > ridiculously clumsy being stuck with Matlab's rather restricted facilities
                  > > for doing other things than standard mathematical work.
                  > >
                  > > Does anyone know of good techniques (or readily available software) for
                  > > achieving a cross-language support between Python and Matlab?
                  > >
                  > > Carl[/color]
                  >
                  > Perhaps you will find this useful:
                  >
                  > http://claymore.engineer.gvsu.edu/~s...hon/pymat.html[/color]

                  I'd recommend looking at

                  <http://mlabwrap.source forge.net/>

                  instead (but then I'm the author). It's based on pymat but contains several
                  critical bugfixes and a high-level interface from python to matlab (e.g. you
                  can just do mlab.plot([1,2,3]) or x = mlab.sin(3)). I'll need to update a
                  couple of things, but on the whole it appears quite stable -- people have
                  succefully used it under windows, linux and os x.

                  'as

                  Comment

                  • Sébastien Boisgérault

                    #10
                    Re: Calling Python from Matlab

                    [color=blue]
                    > Also, can you elaborate on what (if anything) it is about Matlab that
                    > you feel you can't replicate in Python? Are you aware of matplotlib and
                    > numpy?[/color]

                    The features provided by some matlab 'toolboxes' (libraries in
                    matlab-speak)
                    are lacking, and are beyond what numpy + scipy may provide. Some
                    projects
                    done in Matlab could easily be translated to Python, but probably not
                    the control
                    engineering kind for example -- the algorithms provided by the control
                    toolbox,
                    the identification toolbox, etc. are standard tools in the field, and
                    were
                    implemented by domain experts.

                    Don't get me wrong. There are A LOT of scientific projects that can be
                    done
                    with Python, and I'd rather cut my hand than do some Matlab programming
                    when I can avoid it.

                    I also believe that the work involved in the proper installation of
                    numpy +
                    scipy + matplotlib is far beyond the average Matlab user ability (check
                    the
                    amount of "installati on problem" on the numpy mailing-list ...). But
                    for sure,
                    the work done in these libs is just great and their community is
                    extremely
                    reactive and helpful.

                    Last thought: the "All Python behavior in the presence of infinities,
                    NaNs, and
                    signed zeroes is a platform-dependent accident" meme still worries me
                    from
                    time to time ... But, hey, that's probably just me :)

                    Cheers,

                    S.B.

                    Comment

                    Working...