Pass data between two Matlab?

조회 수: 26 (최근 30일)
Abolfazl Nejatian
Abolfazl Nejatian 2020년 9월 26일
답변: Walter Roberson 2020년 9월 26일
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
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
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);'])

Walter Roberson
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

카테고리

Help CenterFile Exchange에서 Parallel Computing Fundamentals에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by