How to prevent Matlab from GPU switching?
Disable automatic graphics switching in the Energy Preferences Panel of System Preferences. This will force your MBP to only use the dedicated GPU, not the discrete GPU.