Communicate between Max/MSP and MATLAB
Hi,
I'm looking to have Max serve as the front-end GUI for calling a few MATLAB scripts I've written. I've been searching around the internet for a few days now and have yet to find a working solution for communicating between the two programs. I did try using CNMAT's "matlabcommunicate" object, but it seems to be broken or incompatible. Does anyone know of way to transfer data between the two? All I need to do is either send data from a buffer~ to a MATLAB array, or vice versa. The CNMAT object apparently does this, but I cannot get it to work (the object doesn't load correctly).
Here's a link to the files:
http://cnmat.berkeley.edu/files/maxdl/OSX-CFM/matlabcommunicate_1.1.2.sit
And here's the error I get:
matlabcommunicate: unable to load object bundle executable
2010-03-08 19:29:06.404 MaxMSP Runtime[757:207] Error loading /Applications/Max5/Cycling '74/max-externals/matlabcommunicate.mxo/Contents/MacOS/matlabcommunicate: dlopen(/Applications/Max5/Cycling '74/max-externals/matlabcommunicate.mxo/Contents/MacOS/ma
tlabcommunicate, 262): no suitable image found. Did find:
/Applications/Max5/Cycling '74/max-externals/matlabcommunicate.mxo/Contents/MacOS/matlabcommunicate: mach-o, but wrong architecture
Thanks
Hello
did you read the How-to-use-it text ?
Here it is
Go to a bash shell and set the shell variables MATLAB,
DVLD_LIBRARY_PATH, and PATH, then start Max from this terminal.
You should be able to cut and paste this text into a Terminal window:
bash
# Note this kludge to get /Applications/MATLAB701, /Applications/MATLAB704, etc:
MATLAB=echo /Applications/MATLAB*
export MATLAB
DYLD_LIBRARY_PATH=$MATLAB/bin/mac:$MATLAB/sys/os/mac:$DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH
PATH=$MATLAB/bin:$PATH
export PATH
open /Applications/MaxMSP 4.5/MaxMSP 4.5.app
For Remote:
Start the X server on your machine
xhost +[ip_address_of_matlab_server]
Make sure your path on the matlab server includes the Matlab directory
Type this in a terminal on my laptop to run Matlab on the G5:
ssh 128.32.122.217 ls
ssh 128.32.122.217 "/bin/csh -c 'setenv DISPLAY 128.32.122.70:0; printenv'"
ssh 128.32.122.217 "/bin/csh -c 'setenv DISPLAY 128.32.122.70:0; /usr/X11R6/bin/xclock'"
ssh 128.32.122.217 "/bin/csh -c 'matlab -nojvm'"
ssh 128.32.122.217 "/bin/csh -c 'setenv DISPLAY 128.32.122.70:0; matlab'"
CNMAT does not distribute an intel or ub version at the moment. that's why you got :
/Applications/Max5/Cycling '74/max-externals/matlabcommunicate.mxo/Contents/MacOS/matlabcommunicate: mach-o, but wrong architecture
So assuming I won't be able to use matlabcommunicate, are there any other ways of doing this? How about creating a Max external in C that calls the matlab engine?
Just to complete this topic, I did find a working solution. Andy Schmeder at CNMAT wrote some MATLAB code for sending and received OSC messages over UDP. In combination with udpsend/receive in Max, I was able to send numbers, strings, and lists between the programs. Straight forward and very easy to use.
Here's the link if anyone else is interested:
http://andy.schmeder.net/software/
Thanks again
Hello
Would it be possible to give a bit more information about your solution?
For my bachelor project I need both Max/MSP and MATLAB, and the plan was to send the data (numbers) from Max to MATLAB via osc/udp.
I had already discovered the Matlab OSC toolbox, but I can not get it to work...When I try the example .m files (like osc_pingpong_a.m), it just times out without receiving anything. Maybe I should contact Andy Schmeder himself about this, but probably I'm just doing it wrong.
deepdrumms, could you give an example of an .m file that can receive data sent with 'udpsend' in Max?
Thanks
ps. I'm very (very!) new to Max/MSP, with MATLAB I'm a bit more familiar :)
I see that this thread is six years old... but finger's crossed, can someone help? I'd like to send data directly to Max from MatLab. The link to Andy Shmeder's site no longer seems active -- can you help deepdrumms? I'm working on a PC and have tried applying the bash code (but I think my directories are wrong... can you help me understand what each of these directories mean and how I can customize it to my computer:
DYLD_LIBRARY_PATH=$MATLAB/bin/mac:$MATLAB/sys/os/mac:$DYLD_LIBRARY_PATH
Any tidbit of direction would be super helpful... I'm stuck.