Clearing variables
Quick reference
To remove values from variables, type:
clear var_name1, var_name2, var_name3
Variables of any type can be cleared using a clear statement:
clear var1, var2, .... varn
var1 to varn are any valid Quantum variable or range of variables. For example:
clear c(109,180), t(1,200), myarray(29,33), myint, myreal
More information
Data variables are reset to blank, integer variables are reset to 0 and real variables are reset to 0.0.
Variables can also be cleared using assignment statements (for example, t1=0), but there are advantages to using clear instead:
▪clear is much easier to write.
▪With clear, the compiler checks that the subscripts are in the correct range (for example, 1 to 33 if ‘myarray’ has only 33 cells); this is not possible with the loop method because the subscript is a variable. However, if you use variables as subscripts with clear (for example, clear c(t1,t1+5) subscript checking once again cannot be done.
See also