How to build model using Simulink Coder on the command line

If you want to compile MyProgram.slx using Simulink Coder, you can use batch mode:

matlab -batch 'slbuild("MyProgram") ; exit'