Code covered by the BSD License  

Highlights from
Define/Undefine Constants

2.66667

2.7 | 3 ratings Rate this file 7 Downloads (last 30 days) File Size: 4.15 KB File ID: #13622

Define/Undefine Constants

by

 

10 Jan 2007 (Updated )

Define and undefine constant variables with no use of global

| Watch this File

File Information
Description

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

MATLAB release MATLAB 7.3 (R2006b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
16 Sep 2009 can baran

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.

19 Aug 2008 m m

Thanks!
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'...)

12 Jan 2007 John D'Errico

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-)

Contact us