Python opening multiple thread of matlab

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

    Python opening multiple thread of matlab

    Hello Python Users,

    I've been trying to run multiple thread of Matlab by calling its com
    object
    via python. However, I keep getting error message that says Python
    can't
    find the attribute of certain function that I want to execute in
    Matlab.

    I know the com function is exist, it works just fine if I don't run
    within thread.
    Below is my sample code, any helps or comments are appreciated.

    Thanks,
    Tanto

    import threading
    from win32com.client import Dispatch


    class MyThread ( threading.Threa d ):

    def __init__(self,m atlab_command):
    self.matlab_com mand = matlab_command
    self.matlab_obj ect = Dispatch('matla b.application.s ingle')
    threading.Threa d.__init__(self )

    def run(self):
    execute = getattr(self.ma tlab_object,'Ex ecute')
    execute(self.ma tlab_command)

    def awesome_dud(sel f):
    execute = getattr(self.ma tlab_object,'Ex ecute')
    execute(self.ma tlab_command)


    a = MyThread('a=1:1 :100')
    b = MyThread('b=1:1 :200')

    # Running matlab function through thread (It's not working)
    # =============== =============== =============== ============

    a.start()
    b.start()
    a.join()
    b.join()

    # Running matlab function not through thread (it's working)
    # =============== =============== =============== ============
    a.awesome_dud()
    b.awesome_dud()

Working...