these two functions define and undefine variable constants like the #define
preprocessor command in C.
No global variables are used.
Tested on R2006b
See help for each file
this .m file has a subtle bug that i didn't bother to fix. As the previous person commented it has troubles redefining (overwriting) the constants
The idea is a good one! It did save me the trouble of declaring global variables and invoking the global variables in subfunction where i need the global variables, but as it sometimes fails (and i dont know when exactly) to overwrite the constants, i stopped using this define.
I seems to work good on Matlab 7.5, if you don't need to redefine during the execution.
(...on Matlab 7.5, I have troubles redefining constants, the value is not updated, even with 'undefine/define'...)
An interesting idea. Nicely implemented.
I did get a chuckle over the example used - defining pi as 3. Some boards of education might even agree. 8-)