本文整理匯總了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()