I don't know if you are aware of the some features of Mathematica.
If not they could be of great help for you.
It is related to the way you can write and regroup some scripts (I don't know matlab, so no comparaison possible)
Say you have severals scripts you have developped in small cells :
script 01 :
Print["hello world"];
1+1
hello world
2
script 02 :
Print["how are you ?"];
1+2
how are you ?
3
First thing you can do is to set the options "Initialisation Cell" to the input cells (in blue), so they are automaticaly executed at Mathematica startup.
But maybe you only want to give a name to your scripts but don't want to execute them at Mathematica startup. Here, the idea is to execute these scripts by "calling" there name. (I suppose this is what you do with Matlab). Here is how to do this :
script01:=(
Print["hello world"];
1+1
)
When you evaluate the cell above, apparently nothing happen, but in fact script01
is memorized by Mathematica. To execute this script, just write script01
in a new cell and evaluate it :
script01
hello world
2
So a friendly procedure to develop some small pieces of scripts that are intended to become a large one is :
- write and test small pieces in small cells. The results of the tests appears just under the cell.
- give a name to the script as explain above.
- if needed you can test it (or a modified version) simply by calling his name, either in the cell that define the script or in a new cell (see (1) to understand why it can be interesting to use a new cell)
- set the option "Initialisation Cell" in the cell that contain the script definiton.
Then each time you call Mathematica, the definition of the scripts are automaticaly evaluated. You can call the scripts by their name everywhere you want, in particular you can group them in a single cell, the only one you have to evaluate to execute your menu of scripts:
script01
script01:=(
Print["hello world"];
1+1
)
Test :
script01
"hello world"
2
Test OK
script02
script02:=(
Print["how are you ?"];
1+2
)
Test :
script02
how are you ?
3
Test OK.
Menu :
script01
script02
hello world
2
how are you ?
3
(1) According to what is explained after : Simply because if do not want that your script is executed at Mathematica startup, use a separate cell
NOTE I use words like "script", "name", "calling" to be understable. In reality these words doesn't exist in Mathematica's world because they are included in the concepts of "expression" and above all "evaluation" in their generality (they are even not special cases)
"myProgram.m"
and then run every expression therein usingGet
like<<"myProgram.m"
$\endgroup$Evaluation->Evaluate notebook
. Another is to use the command line , something likemath.exe < my_script.m > my_output.out
$\endgroup$