I need to pass data back and forth repeatedly between Grasshopper and MATLAB.
In this post, Mostapha showed one way of doing this. This works, however the method seems a bit slow and prone to errors since it relies on writing and deleting a file, using pause() functions and a Grasshopper timer. He does mention:
Note: Obviously this method is not the most sophisticated method that you can use but it is simple enough to set-up easily and fast.
So my question is: What is a more sophisticated way of doing this?
@MaxMarschall The post you mention is 6 years ago. Could you tell what are going to do for Matlab - Grasshopper Interaction .If only for visualization and basic statics, Grasshooper is enough for you.
The setup was a bit too complicated to explain here, but in essence: I need to create a loop where I compute something in Grasshopper (or GHPython), send the results to Matlab, compute something in Matlab based on that data, then send results back to Grasshopper and so on.
The tricky thing here seems to be the timing. I’d like Grasshopper and Matlab to each “know” when the other has finished its operation, and only then immediately do their own operation. Is that even possible?
Is it possible to compile your Matlab code and run it as an executable? That can make everything much cleaner as you can run Matlab as a subprocess and wait for it to be finished.
As I know, you should first install the matlab.engine API for python, then use the GHCpython component(https://www.food4rhino.com/app/ghcpython) to link the two.
I’m trying to do the same. I already have a long script in Matlab (actually was my professor Ph.D.) and I need to call this on my gh workflow and retrieve its result, this has to be automated since I am performing an optimization.
Could you already solve this?