I would like to keep my gcc 4.9 but let Matlab use gcc 4.7 because Stable Debian does not support 4.7, as observed in the thread Debian Jessie: Why gcc-4.7 conflicts with gcc-4.8? I do the following but nothing in Jessie because Matlab 2016 wants gcc 4.7.x# https://packages.debian.org/search?keywords=gcc-4.7apt-cache search gcc-4.7 However, I think apt-get is not the way to go because I just want to get gcc-4.7 in my system for Matlab, not for any other purpose. Example of the warning when using wrong gcc in MatlabMEX completed successfully.Building with 'gcc'.Warning: You are using gcc version '4.9.2'. The version of gcc is not supported. The versioncurrently supported with MEX is '4.7.x'. For a list of currently supported compilers see:http://www.mathworks.com/support/compilers/current_release. OS: Debian 8.5 64 bitLinux kernel: 4.6 of backportsHardware: Asus Zenbook UX303UA     
How to get gcc-4.7 to /usr/bin/gcc-4.7 as second gcc in Debian Jessie?
debian;gcc;matlab
This doesn't answer your question as stated, but it solves the underlying problem: you can upgrade to Matlab 2016b, which supports GCC 4.9.