MATLAB: Problem with variable values across scripts

scriptsvariablesworkspace

Hello all,
I'm trying to initialize variables (say Var1=100 and Var2=[-1 -1 -1 -1]) in Script1, then call another script (Script2) which updates the values of Var1=80 and Var2=[8 9 12 13]) within functions. When the code returns from Script2 to Script1, the values return to the way they were i.e. Var1=100 and Var2=[-1 -1 -1 -1].
I'm unable to retain the values no matter what I do. tried initializing variables as global, persistent.
Am I missing something here? is there a way I can retain the values of variables across scripts?

Best Answer

That would happen if the change to the variables is being made inside a function call. The change would to be made inside pure script levels to get it to stick.
Note: "run" is a function call.