Make multiple Matlab sessions communicate - matlab

Is there a way to make multiple Matlab sessions communicate (the session 1 accessing to the workspace of the session 2, for example)?
Thank you

You can do this in a few ways. For example using sockets or write to/read from files. One instance writes while the other reads, in each case.

Related

How to properly use spmd in matlab with handle classes and synchonize data between workers

my problem is following:
I have a handle class with many objects and I want to link them to each other.
So my vertex(1) from my class vertex needs to be linked to vertex(2) and vertex(3), so that my vertex(1) has the properties vertex(1).neighboor_vertex=vertex(2) (and vertex(3)).
This is just one thing that has to be done (actually I need to link and relink different classes to each other and because its millions of objects and want to do it in parrallel and the fact that linking is not working in parallel stops me from following steps).
So while worker 1 links vertex(1) to vertex(2), no other worker should be able to change the properties of both, they can lets say link 5 to 7 or so, and when the linking is done the new link of vertex(1) to vertex(2) and vertex(2) to vertex(1), needs to be updates to all other workers, so that when another worker wants to link vertex(3) to vertex(1), it has to know that it is alreay linked to vertex(1), otherwise there would be 2 different versions of vertex(1), one linked to vertex(2) and one linked to vertex(3).
So for the blocking that multiple workers cant change the the vertex I would need something like a mutex within the spmd, otherwise it wouldnt be threatsave...
What would be the best way to do this in Matlab?
Many Thanks in advance
Best regards

Drools global variable initialization and scaling for performance

Thanks in advance. We are trying to adopt drools as rules engine in our enterprise. After evaluating basic functionality in POC mode, we are exploring further. We have the following challenges and I am trying to validate some of the options we are considering. Any help is greatly appreciated.
Scenario-1: Say you get USA state (TX,CA,CO etc) in a fact's field. Now you want the rule to check if the 'state value on the fact' exists in a predetermined static list of state values(say the list contains three values TX,TN,MN).
Possible solution to Scenario-1: 'static list of state values' can be set as a global variable and the rule can access the global variable while performing the check.
Qustions on Scenario-1:
Is the 'possible solution to scenario-1' the standard practice? If so, is it possible to load the value of this global variable from a database during rule engine(KIE Server) startup? If yes, could you let me know the drools feature that enables us to load global variables from a database? Should a client application (a client application that calls kie-server) initialize global variables instead?
Scenario-2: We want to horizantally scale rule execution sever. Say we have one rule engine server(kie-server) exposing rest-api. Can we have multiple instances running behind a loadbalancer to have it scale horizontally? Is there any other way of achieving the scalability?
Q1: It depends. The usual solution for a small, rarely (if ever) changing set that is used just in a single rule is to put it into the rule, using the in operator. If you think you might have to change it or use it frequently, a global would be one way of achieving that but you must make sure that the global is initialized before any facts are inserted.
There is nothing out-of-the-box for accessing a DB.
Q2: A server running a Drools session is just another Java server program, so any load balancing applicable to this class of programs should apply to a Drools app as well. What are you fearing?

Is there a way to communicate between workspaces of two Matlab Instances?

Hi I have two Matlab instances running two simulink models. I want to use the Workspace data of Matlab Instance1 in Matlab Instance 2. Is there any way to do this?
As mentined by #thewaywewalk, you can save/load .mat files as communication.
Another option is to use the Matlab COM Automation server. Depending on your application, it may be overkill, but you don't need any extra toolboxes. Here is the documentation: Matlab COM Automation Server.
I got this work helpful in communicating with two matlab instances.
Just use 'localhost' in place of server.

Separate processes that communicate via a NSpipe

I need to realize a communication between two application using NSPipe channels.A NSPipe has to write data and the other has to read the data (Bi-directional) that will communicate between separate process in two different applications.
For example such things in c# can be easy done with NamedPipeClientStream, NamedPipeServerStream classes where pipes are registered by id string.
Any suggestion how to achieve it in Objective-C?
With regards,
Vadivelu

iPhone - Write to a file without collision when multiple NSURLConnection ends

I have a CONNECT object that make HTTP calls using :
NSURLConnection* connection = [NSURLConnection connectionWithRequest:urlRequest delegate:self];
In the - (void)connectionDidFinishLoading:(NSURLConnection*)connection method, I write things to a file.
I may have mutiple HTTP calls sent from multiple instances of CONNECT objects, so I suppose there is a risk that those CONNECT objects write into the file at the same time when the connection ends.
Is this correct ? If yes, how may I prevent this ?
If you have only one thread then there won't be any problem as the delegates will be executed on the same thread.
Delegates are executed one after another in single threaded environment. There wont be a case when your DelegateMehtod1 is accessing the file and it has paused due to DelegateMehtod2 and then DelegateMehtod2 access the file. This happens only in multiple threads not in multiple delegates with one thread
If it is multi-threaded environment then you have to synchronize your file accessing code.
Two things:
1) If you are running all the NSURLConnections on a single thread (most likely the main thread), then you won't have any issue with writing to a file as long as you're doing the entire write (ie. open/create, write, close) within the connectionDidFinishLoading method. This is because a single thread can only be doing one thing at a time.
2) On the design side, do you really want multiple connections to be writing to the same file? If you're creating lots of NSURLConnections, then generally you would want to be able to record them, give them unique filenames and process them separately. This then allows you to know how many connections you currently have in flight, cancel them, and so forth.
If you're just writing some short-lived data to a file while you're doing the processing, then perhaps use unique names for the filenames. Basically, I'm finding it hard to think of a good reason to have lots of concurrent downloads writing to the same file on completion - but perhaps you have one!