MATLAB 监听 TCP/IP 端口

发布于 2024-12-22 16:31:28 字数 279 浏览 0 评论 0原文

我已经看过一些关于这个主题的文章,但其中大部分都是 3-4 年前的文章,我相信以前有人这样做过。有谁知道是否有办法让 MATLAB 程序监听指定的端口号。我正在尝试通过本地网络(或可能是互联网)将信息传输到 MATLAB,并让 MATLAB 处理这些信息?有什么建议吗?

我的另一个选择是将所有内容发送到 SQL 服务器,然后让 MATLAB 轮询该服务器。然而,我担心其速度,因为 MATLAB 需要“实时”或尽可能接近地吐出内容。

注释信息将从 iPhone 获取并通过 Wi-Fi 传输

I have seen already a few articles about this topic, but most of these were from 3-4 years ago and I have to believe someone has done this before. Does anyone know if there is a way to have a MATLAB program that will listen on a specified port number. I am trying to transmit information to MATLAB over a local network, or potentially internet, and have MATLAB do stuff with it? Any suggestions?

My other option is just to send everything to an SQL server, and then have MATLAB poll this server. I however was concerned about the speed of this because MATLAB needs to be spitting out stuff in "real-time" or as close to as possible.

Note information will be taken from an iPhone and transmitted over Wi-Fi

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你与清晨阳光 2024-12-29 16:31:28

我会使用通过 Matlab 连接的语言,例如通过 mex 文件的 C 语言或 Java。

I would use a language which is interfaced through Matlab, such as C over mex-files or Java.

朕就是辣么酷 2024-12-29 16:31:28

这是我的例子。 Android 用户将文件名和文件发送到 matlab TCP 服务器。然后,matlab TCP 服务器接收一行文件名和文件数据。

   t = tcpip('0.0.0.0', 8000, 'NetworkRole', 'Server');
    set(t, 'InputBufferSize', 900000);

    fprintf('waiting for client');
    fopen(t);
    pause(1);

    fprintf('client connected');

    fid = fopen('temp','w+');
    file_name = fgetl(t);

    % read first line

    while (get(t, 'BytesAvailable') > 0 )
        pause(2);
        t.BytesAvailable
        data = fread(t, t.BytesAvailable);
        pause(2);
        fwrite(fid, data);
    end

    copyfile('temp',['../../data/' file_name]);

    fclose(t);
    fclose(fid);

This is my example. Android user sends a file name and the file to matlab TCP server. Then, matlab TCP server receives a line which is file name and file data.

   t = tcpip('0.0.0.0', 8000, 'NetworkRole', 'Server');
    set(t, 'InputBufferSize', 900000);

    fprintf('waiting for client');
    fopen(t);
    pause(1);

    fprintf('client connected');

    fid = fopen('temp','w+');
    file_name = fgetl(t);

    % read first line

    while (get(t, 'BytesAvailable') > 0 )
        pause(2);
        t.BytesAvailable
        data = fread(t, t.BytesAvailable);
        pause(2);
        fwrite(fid, data);
    end

    copyfile('temp',['../../data/' file_name]);

    fclose(t);
    fclose(fid);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文