MATLAB TCP Server and Python Proxy Server for OPCloud

バージョン 1.0.0 (6.43 KB) 作成者: Joy
A MATLAB TCP server and a Python FastAPI proxy to run MATLAB functions remotely. Supports HTTP requests and FastAPI routing.
ダウンロード: 2
更新 2025/2/25

ライセンスの表示

MATLAB TCP Server and Python Proxy Server for OPCloud
This repository provides two methods to serve MATLAB functions remotely:
1. A TCP-based MATLAB server using Java sockets.
2. A Python proxy server using FastAPI to communicate with MATLAB.
Method 1: MATLAB TCP Server
This method runs a TCP server in MATLAB to execute functions via HTTP-like requests.
Running the MATLAB TCP Server
Start the server in MATLAB on port 4000:
serve(4000);
The server will start and wait for incoming connections.
Example API Call
Call MATLAB functions remotely using an HTTP request:
Example Function (functions/displacement.m)
function s = displacement(v_init, v_final, time)
s = (v_init + v_final)/2 * time;
end
Example Request (Browser or OPCloud)
http://localhost:4000/displacement?v_init=1&v_final=5&time=2
Expected Response
6
Stopping the Server
Close the figure window to shut down the server.
Requirements
MATLAB 2020 or later
Java (included with MATLAB)
Method 2: Python Proxy Server
This method runs a FastAPI-based proxy server in Python, which forwards requests to MATLAB.
Installing Dependencies
Ensure you have Python installed, then install the required dependencies:
pip install -r requirements.txt
Running the Python Proxy Server
Start the FastAPI server on port 4000:
fastapi run app.py --port 4000
Making API Calls
Call MATLAB functions through HTTP requests:
http://localhost:4000/displacement?v_init=1&v_final=5&time=2
Expected Response
6
Stopping the Server
Stop the FastAPI server with CTRL+C.
Requirements
Python 3.8 or later
MATLAB Engine API for Python (installed automatically via requirements.txt)

引用

Joy (2025). MATLAB TCP Server and Python Proxy Server for OPCloud (https://jp.mathworks.com/matlabcentral/fileexchange/180232-matlab-tcp-server-and-python-proxy-server-for-opcloud), MATLAB Central File Exchange. に取得済み.

MATLAB リリースの互換性
作成: R2024b
R2007b 以降のリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
タグ タグを追加

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

functions

server_functions

バージョン 公開済み リリース ノート
1.0.0