Yes you can do this. A simple example:
In the command window, enter global G
and G=2
.
Then make a simple function, e.g.:
function incG
global G
G=G*2;
disp(G)
Run incG
from the command window and see what happens. You can also modify the value of G
in the command window in between executing incG
. You do have to be careful that G
exists and has the correct value when you run incG
.