Matlab 会话(sessions)多开,运行多个程序

    xiaoxiao2021-03-25  131

    matlab R2012a 之后提供了会话多开功能,可以开多个会话,但是每个会话的占用内存都和原来一样多,运行前请先预留内存空间。

    可以用这个功能建立服务机和客户机通信,调试程序等等。

    本文中给出TCP 服务器和客户机通信示例。


    1.找到matlab安装目录;

    unix:应用程序中找到matlab-右键(显示包内容)-bin-matlab windows: 安装目录-bin-matlab


    2.制作替身/快捷方式


    3.运行替身/快捷方式 在已经打开matlab的基础上,运行快捷方式,可以看到运行了两个matlab程序(要开多个类似)


    4.Server

    这里给出mathwork support team给的简单通信例子; 一个会话运行Server,另一个会话运行Client

    t = tcpip('0.0.0.0', 30000, 'NetworkRole', 'server'); %Open a connection. This will not return until a connection is received. fopen(t); %Read the waveform and confirm it visually by plotting it. data = fread(t, t.BytesAvailable); plot(data);

    5.Client

    %Create a waveform and visualize it. data = sin(1:64); plot(data); %Create a client interface and open it. t = tcpip('localhost', 30000, 'NetworkRole', 'client'); fopen(t) %Write the waveform to the server session. fwrite(t, data)

    6.运行结果


    补充: 关于更详细的Socket通信可以访问mathworks 关于matlab会话多开的想了解matlab团队的答案的可以访问MathWorks Support Team

    转载请注明原文地址: https://ju.6miu.com/read-9613.html

    最新回复(0)