matlab production server(2018b)的下载安装及配置

MATLAB production server这个强大的工具完成MATLAB程序在各个应用程序上的部署,
我计划使用Python实现对MATLAB的调用,于是想通过这一工具实现。
但是由于它是2017版本才推出的新功能,国内的资料极少,因此参考官方文档,一步步完成。(一路上遇到了各种错误TAT)

第一步:下载安装MATLAB
选择带有MATLAB producton server的,版本为2017a及以上
这一步不多说,网上各种破解版本都有,实在不行,淘宝也可以~
第二步:安装 License Server
再次运行安装MATLAB的 setup.exe,这次仅仅选择 license manager那一栏;
这一步非常重要!不能忽略,否则后面的进行不下去。具体操作如下:
在这里插入图片描述
第三步:安装MATLAB runtime
在官网选择和当前MATLAB版本一样的下载安装。下载完成后记得把下面三行加入系统路径中(要根据自己安装的位置修改哦)

D:\Software\MATLAB\MATLAB Production Server\R2018b\script;
D:\Software\MATLAB\MATLAB Production Server\R2018b\script\mps-setup;
D:\Software\MATLAB\matlab runtime\v95\runtime\win64

第四步:安装dashboard
这是一个可视化的工具,可以把大家从cmd命令解救出来,效果如下所示:
在这里插入图片描述
只需通过点击创建、开启新的服务。
安装如下所示:(首先在cmd中进入MATLAB production server文件夹)

mps-dashboard.bat setup

启动

 mps-dashboard.bat start

进入

http://localhost:9090

,就是交互的界面了。用户名和密码都是admin
dashboard每次启动的时候都需要setup
注意 这里说的都是Windows系统下的安装。Linux和Mac有所不同。可参考官方文档
https://www.mathworks.com/content/dam/mathworks/tag-team/Objects/m/matlab-production-server-quick-start-guide.pdf
第五步:在dashboard或者cmd下创建一个instance
但是出现了错误
在这里插入图片描述
看来是许可证的问题。
找了半天,终于发现问题所在:
在安装MATLAB和MATLAB production server的时候,要分别把破解文件中的下面两个文件复制到安装目录的bin\win64下面。
在这里插入图片描述
在这里插入图片描述
才可以使用production server哦!
输入

mps-status

成功界面如下所示:
在这里插入图片描述
dashborad成功界面如下所示:
在这里插入图片描述

记住,自己的服务器安装在哪个文件夹中,方便对配置文件的修改:(我的在这里)
在这里插入图片描述
第六步:部署程序
1、编写一个测试用的MATLAB代码,如下:

function a = addmatrix(a1, a2)
%ADDMATRIX Add two matrices
% This function adds the two matrices passed as input. This function is
% used to demonstrate the functionality of MATLAB Compiler SDK. Refer to the
% documentation for MATLAB Compiler SDK C/C++ shared library for more information.
% Copyright 2003-2017 The MathWorks, Inc.
a = a1 + a2;

2、连接server instance;
3、打开MATLAB APP中的production server compile,添加m文件,转换成ctf格式;
在这里插入图片描述
4、打开dashboard—>application,upload刚刚转换好的ctf格式文件;
在这里插入图片描述
5、把ctf文件复制到server instance文件夹下的auto_deploy下;
6、新建Python文件,编写如下代码测试:

import matlab
from production_server import client
client_obj = client.MWHttpClient("http://localhost:9910")
a1 = matlab.double([[1,2,3],[3,2,1]])
a2 = matlab.double([[4,5,6],[6,5,4]])
x=client_obj.addmatrix.addmatrix(a1,a2)
print(x)

得到正确结果如下所示:
在这里插入图片描述
好啦!!!成功完成Python调用MATLAB函数
接下来,进行更复杂函数的调用吧!

猜你喜欢

转载自blog.csdn.net/weixin_40929147/article/details/84532558
今日推荐