06.07.2013 Views

Scilab Bag Of Tricks - Claymore

Scilab Bag Of Tricks - Claymore

Scilab Bag Of Tricks - Claymore

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

will clear all global variables.<br />

2.5.3. Clearing Variables<br />

Chapter 2. Pitfalls<br />

During everyday programming it is not necessary to explicitely remove variables from the work<br />

space. All local variables of a function die on exit from that function anyhow, and the variables in the<br />

global name space usually do not need a special treatment.<br />

However, there are conditions under which it is preferable to completely wipe out a variable. This<br />

happens if one needs to avoid a pollution of the name space e.g. while working with the list of all<br />

variables, who(’local’). The correct command to kill the non-global variable v is<br />

clear v<br />

Note that there are no parentheses. The assignment<br />

v = []<br />

sets v to the empty matrix. It does not remove the variable from the workspace.<br />

Global variables are cleared with the clearglobal function, whose syntax is the same as clear’s<br />

syntax.<br />

There is no need to worry if you do not understand how and why to kill a variable. This feature is<br />

only needed in very rare occasions.<br />

28

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!