I have stopped using a powerful desktop computer at work about a year ago and switched to a laptop (an Zenbook actually). With the switch I have also decided to move to remote virtual machine for all processor hungry computations, many of which are done in Matlab.
I connect to the remote machine using NX protocol and from the beginning I have noticed a strange lag only present in Matlab interface. Actually I think it is a Java problem, because Matlab interface is written in Java, but that is not the point. The point is that this was driving me nuts for half a year and then I have finally decided to solve it and I am posting the solution here for everyone to see. After a bit of searching I found this post that describes a correct configuration for official NX client. Unfortunately I do not use a client with all these options present, so I went looking for a server-based solution.
I have found a configuration file for the NX node, called
/usr/NX/etc/node.cfg. In the file there is a (commented out) option for extra client options with the key AgentExtraOptions. Uncomment the line and modify it to look like this:
AgentExtraOptions = "-nocomposite -noshpix -noshmem"
This way a new session will be started with disabled shared memory extension and disabled emulation of shared pixmaps, which for some reason cause problems with Java Swing GUI (I have no idea why). After that you have to start a new session to see a difference. Now Matlab should work like a charm. Unfortunately other, native applications on Linux (which I am using on the virtual machine) work less smoothly, but I find it less annoying than previous Matlab unresponsive behavior.