當前位置: 首頁>>代碼示例>>Python>>正文


Python Matlab.run方法代碼示例

本文整理匯總了Python中pymatbridge.Matlab.run方法的典型用法代碼示例。如果您正苦於以下問題:Python Matlab.run方法的具體用法?Python Matlab.run怎麽用?Python Matlab.run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pymatbridge.Matlab的用法示例。


在下文中一共展示了Matlab.run方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from pymatbridge import Matlab [as 別名]
# 或者: from pymatbridge.Matlab import run [as 別名]
class MatlabCaller:
    """
    bridging class with matlab
    """

    def __init__(self, port=14001, id=None):
        if id is None:
            id = numpy.random.RandomState(1234)

        # Initialise MATLAB
        self.mlab = Matlab(port=port, id=id)

    def start(self):
        # Start the server
        self.mlab.start()

    def stop(self):
        self.mlab.stop()
        os.system('pkill MATLAB')


    def call_fn(self, path=None, params=None):
        """
        path: the path to your .m function
        params: dictionary contains all parameters
        """
        assert path is not None
        assert isinstance(params, dict)

        return self.mlab.run(path, params)['result']
開發者ID:xiaoyili,項目名稱:xylearn,代碼行數:32,代碼來源:bridge_util.py

示例2: Matlab

# 需要導入模塊: from pymatbridge import Matlab [as 別名]
# 或者: from pymatbridge.Matlab import run [as 別名]
from pymatbridge import Matlab
mlab = Matlab(matlab='/Applications/MATLAB_R2014a.app/bin/matlab')
mlab.start()
res = mlab.run('/Users/yanguango/Lab/SpamFilter/Project/src/PCA.m', {'arg1': 3, 'arg2': 5})
print res['result']
開發者ID:yanguango,項目名稱:spam_filter,代碼行數:7,代碼來源:test.py

示例3: pixels

# 需要導入模塊: from pymatbridge import Matlab [as 別名]
# 或者: from pymatbridge.Matlab import run [as 別名]
            scaled_for_color = math.ceil(32 * pixel_normalized_val + 32)
            if scaled_for_color == 0:
                scaled_for_color = 1
            group["intelligent_icon"][row][column] = scaled_for_color
    if add_struct_comma_to_expr:
        matlab_intelligent_icon_visualization_data_expr = matlab_intelligent_icon_visualization_data_expr + "," 
    else:
        add_struct_comma_to_expr = True   
    matlab_intelligent_icon_visualization_data_expr = matlab_intelligent_icon_visualization_data_expr + "struct('title', '" + group_name + "', 'patches', ["
    add_pixel_comma_to_expr = False
    #flatten the bitmap into a vector of pixels (see matlab/show_icons.m)
    for row in range(row_pixel_count):
        for column in range(row_pixel_count):
            if add_pixel_comma_to_expr:
                matlab_intelligent_icon_visualization_data_expr = matlab_intelligent_icon_visualization_data_expr + ","
            else:
                add_pixel_comma_to_expr = True 
            matlab_intelligent_icon_visualization_data_expr = matlab_intelligent_icon_visualization_data_expr + str(group["intelligent_icon"][row][column])
    matlab_intelligent_icon_visualization_data_expr = matlab_intelligent_icon_visualization_data_expr + "])"
matlab_intelligent_icon_visualization_data_expr = matlab_intelligent_icon_visualization_data_expr + "]"

print("rendering intelligent icon grid")
#initialise matlab bridge
mlab = Matlab(port=4000, matlab=matlab_path)
mlab.start()
#i cant imagine more ghetto way to do this, but it seems to be the only way to pass this data through some bug in the data parsing part of the bridge (Which i didnt write, for the record!!!)
icon_data_expr_encoded = base64.b64encode(matlab_intelligent_icon_visualization_data_expr)
print(icon_data_expr_encoded)
mlab.run(base_dir + "/matlab/show_icons.m", {"encoded": icon_data_expr_encoded})

print("done without errors")
開發者ID:pvnick,項目名稱:tardis,代碼行數:33,代碼來源:analyze.py

示例4: Matlab

# 需要導入模塊: from pymatbridge import Matlab [as 別名]
# 或者: from pymatbridge.Matlab import run [as 別名]
'''
Created on 25 sep 2015

@author: fragom
'''
from pymatbridge import Matlab

if __name__ == '__main__':
    mlab= Matlab(matlab='C:/Program Files/MATLAB/R2012b/bin/matlab.exe')
    mlab.start()
    for i in range(10):
        print mlab.run('C:/IDE/python-matlab-bridge/test.m',{'a':i})['result']
    mlab.stop()
開發者ID:MaximeBaudette,項目名稱:ScriptMAE,代碼行數:15,代碼來源:joke_pymatbridge.py


注:本文中的pymatbridge.Matlab.run方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。