Well, global variables are not encouraged in MATLAB. But, sometimes you may want to initialize an object with some parameters and you would like to access some global parameters as well.
Here is what you can do.
- Create a file (say Params.m) for storing such global variables.
global MY_GLOBAL; MY_GLOBAL = 1;
- Next, include this file in your main .m file.
- Afterthat, in your class file, inside the constructor function (or any other function)
obj.xyz = MY_GLOBAL;
done!