2 Matlabs working together on one PC

4 views (last 30 days)
Hey, I'm working on some project. It's pretty complicated. It's so expanded that I cannot use one Matlab anymore. Neither I cannot do this on threads.
So in first Matlab I'm working on Simulink. I'm saving data with "To File" block, with default properties. It should save data in real-time. Actually I'm collecting data from USB camera and I'm analyzing it.
In second Matlab I'm working with some kind of mobile robot. And there is my problem. I cannot get data from that file from "To File" block. While I'm accessing it, it seems to be empty. All the time Simulink simulation is running. And when I stop Simulation the file is full with informations, but this Simulation must work all the time! I don't know how I can transfer data from first to second Matlab.
I you have any questions I will answer them as soon as I can.

Accepted Answer

Walter Roberson
Walter Roberson on 8 Feb 2014
Perhaps use a TCP block? One side would have to be the server and the other side would have to be the client. Instead of saving to file (if all you are doing is transmitting what is in the file), copy over the network link.
You can form a network link even on the same computer. But if everything is on the same computer, you may also be able to proceed by way of shared memory; see http://www.mathworks.com/help/matlab/import_export/share-memory-between-applications.html
  2 Comments
Artur
Artur on 8 Feb 2014
Edited: Artur on 8 Feb 2014
Hey, thanks for fast answer. I use TCP Send block in Simulink. I put to it Localhost address (127.0.0.1:2). Other properties are default. How can I connect with it in Matlab? I tried this:
t=tcpip('127.0.0.1', 2);
fopen(t);
and Matlab is like:
??? Error using ==> icinterface.fopen at 83 Connection refused: connect
I'm probably doing something wrong because I didn't try this before.
Walter Roberson
Walter Roberson on 8 Feb 2014
The receiver (server) needs to be started first, with NetworkRole http://www.mathworks.com/help/instrument/using-tcpip-server-sockets.html
Note: port 2 is usually reserved and only accessible to administrator. You should use a port number of at least 32768 to avoid that problem.

Sign in to comment.

More Answers (1)

per isakson
per isakson on 8 Feb 2014
The documentation says:
"The block writes to the output file incrementally, with minimal memory overhead during simulation. If the output file exists when the simulation starts, the block overwrites the file. The file automatically closes when simulation is complete. If simulation terminates abnormally, the To File block saves the data it has logged up until the point of the abnormal termination."
That explains "While I'm accessing it, it seems to be empty". The file is not closed.

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!