About Site Map Submit Contact Us Log in | Create an account
Create an account Log In
Average Rating
User Rating:
Visitors Rating:
My rating:

Write review
See full specifications

scripts default iconUser Defined Constants (Scripts) Publisher's description

Did you ever want the ability to define a special constant that is seen by and used in all of your functions

Did you ever want the ability to define a special constant that is seen by and used in all of your functions, without needing to create global variables?

For example, suppose you used the golden ratio often in your work. Rather than creating a global variable named phi, or being forced to pass a variable around as an argument to your functions, I'll just use defcon to do the work for me.

>> defcon('phi',(1+sqrt(5))/2)

Here, I used defcon to create a new function called phi on my search path, that acts like the ones and zeros functions.

>> format long g
>> phi
ans =
>> phi(1,2)
ans =
1.61803398874989 1.61803398874989

phi is now a matlab function, that can be used inside other functions without any further effort. In fact, phi even has help defined, done automatically by defcon.

>> help phi
phi - User Defined Constant:

phi(N) is an N-by-N matrix filled with 1.6180339887498949.

phi(M,N) or phi([M,N]) is an M-by-N matrix of 1.6180339887498949.

phi(M,N,P,...) or phi([M N P ...]) is an M-by-N-by-P-by-...
array of 1.6180339887498949.

phi(SIZE(A)) is the same size as A and all 1.6180339887498949.

phi with no arguments is the scalar 1.6180339887498949.

see also: ones, zeros, nan

This means that from now on, the value of phi is defined to any function or script you will use. Because phi is now a function on your search path, it will also be available to you the next time you start MATLAB too. Of course, you must still be careful, as if you name a variable phi, matlab will find the variable first.

Deletion of a defined constant is easy enough too. The new function will be stored in the same directory that defcon resides in.

>> delete(which('phi'))

See that now phi is gone from my system.

>> phi
Undefined function or variable 'phi'.

The usual caveats apply here. Be careful in creating the name of a constant that is also the name of an existing matlab function or command. And if you already have a variable with that name, again there will be a problem.

System Requirements:

MATLAB 7.5 (R2007b)
Program Release Status: New Release
Program Install Support: Install and Uninstall

User Defined Constants (Scripts) Tags:

Click on a tag to find related softwares

Is User Defined Constants (Scripts) your software?

Manage your software

Most Popular

scripts default icon ASK, OOK, FSK, BPSK, QPSK, 8PSK modulation 1.1
ASK, OOK, FSK, BPSK, QPSK, 8PSK modulation contain several functions for digital modulation simulation
scripts default icon Simulink Communication Labs 1.1
Simulink Communication Labs allows you to learn communication systems in greater depth.
scripts default icon M-QAM modulation and demodulation 1.1
M-QAM modulation and demodulation is the QAM modulation and demodulation tech.
scripts default icon LZW Compression/Decompression 1.1
LZW Compression/Decompression - Updated LZW compressor and decompressor with reasonable performance
scripts default icon InSPIRE utility to plot a 2D displacement field (Scripts) 1.0
This program plots the deformation field (displace vectors) contained in vector.txt.