Pass data between two Matlab?
23 次查看(过去 30 天)
显示 更早的评论
Hi
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,
Nejatian
1 个评论
Mohammad Sami
2020-9-26
Can I check if you must run the two process separately. You can potentially use parpool and submit a processing task to it using parfeval. You can get a callback with the processed data once task is completed. If you have r2020a and later you can use the thread based parpool to potentially further reduce over head of passing data between process.
回答(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.
Something like:
myDataLocally = evalin('base', ['load(myfile);'])
0 个评论
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Parallel for-Loops (parfor) 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!