There are two MATLAB toolboxes that can compile (most) MATLAB code to an executable. When the executable is run, a copy of the internal MATLAB engine is started up that can run the code almost exactly the same as if you were running interactively. When either of the two toolboxes is used, the resulting executable is royalty-free and does not require that MATLAB itself be installed in order to run the program, but does require that a (free) copy of the MATLAB run-time library be installed on the user machine.
The executables produced by the above two toolboxes can only be used to run exactly what was programmed into them, not general MATLAB programs. For example if you developed a MATLAB program to (say) detect comets, then you would be able to use VS to call over to the pre-written program in order to detect comets, but you would not be able to do new work such as (say) draw a Snoopy calendar (not unless that was also programmed in to the executable.) The licenses on the two toolboxes require do not permit them to be used for general calculations, only for pre-programmed tasks.
You would not be able to access the MATLAB code using these toolboxes (other than as plain text files that no longer have a connection to what is running.) In particular, without MATLAB itself and a copy of the toolboxes, you would not be able to modify the MATLAB code and run the new code.
The two toolboxes I mention are both moderately expensive, around $US5000 each.
There is also a MATLAB toolbox that can take a subset of MATLAB and generate C or C++ code from it, which you can then incorporate into projects or compile as desired. This might involve calling into mathematical libraries (such as to do fft), but does not involve a MATLAB run-time library. When this toolbox is used, the resulting code is royalty-free and does not require that MATLAB itself be installed on the user system, and does not require that the MATLAB run-time be installed on the user system.
The code produced by this third toolbox can only be used to run exactly what was programmed into it, not general MATLAB programs. Not much is provided in the way of graphics: this toolbox is intended for using MATLAB as a prototyping language and then generating efficient code to be used as library functions. The licence on this toolbox also does not permit it to be used for general calculations, only for pre-programmed tasks.
You would not be able to access the MATLAB code using this third toolbox (other than as plain text files that no longer have a connection to what is running.) In particular, without MATLAB itself and a copy of the toolbox, you would not be able to modify the MATLAB code and run the new code.
This third toolbox I mention is fairly expensive, about $US9000.
If you want to be able to call out from VS to MATLAB to use MATLAB as a computational engine for whatever is asked to be done (as opposed to executing routines you have pre-programmed and used one of the expensive toolboxes to compile), then you need a MATLAB license and need to install MATLAB on the machine. (Though with careful programming, you just might be able to access a licensed copy of MATLAB installed on a server.) Only if you have a MATLAB license and MATLAB installed would you have the possibility of seeing the MATLAB code and modifying it and running the new code.