Pass data between two Matlab?
9 ビュー (過去 30 日間)
i have two different codes.
first code evaluates something on a big data and then write it on a Mat file.
second is an App designer file that lunch as a WebApp with Matlab Web App Server.
the problem is writing a file from the first code take long around 34Sec and reading that file from WebApp takes around 15Sec.
and i should repeatedly do this process. the problem is when I use the Load function on my WebApp during that 15 Sec all of the functionality of that app was cease. so I'm seeking a way that can pass data between these two separate Matlabs without writing and reading them from local drive.
thanks in advance,
回答 (2 件)
Chris 2020 年 9 月 26 日
You might be able to load the data in the base workspace then pull it into the app, I am not sure apps would halt while something is going on in the base ws.
myDataLocally = evalin('base', ['load(myfile);'])
Walter Roberson 2020 年 9 月 26 日
- you can use tcp/ip to send data between distinct processes
- you can use one MATLAB with two spmd workers, and use labSend and labReceive to transfer data between workers -- however you have the problem that spmd workers do not have access to the display
- you can use one MATLAB running the app designer code with one parpool or parfeval worker, and use a parallel data queue to send data back from the worker to the client; https://www.mathworks.com/help/parallel-computing/parallel.pool.dataqueue.send.html
- If you are on Mac or Linux you can look in the File Exchange for the shared array contribution, which uses operating system shared memory support to make data available to multiple processes. In theory the same technique can be used for Windows but if I recall correctly the FEX contribution would need some editing. Also, it is possible that the FEX contribution will not work correctly with releases since MATLAB changed how it stores complex values
- instead of saving your file to disk, create a "ramdisk" that emulates a file system in memory
- if you must save to disk, make it an SSD for performance