本文整理汇总了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']
示例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']
示例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")
示例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()