Getting Started |
The eval Function
The eval
function works with text variables to implement a powerful text macro facility. The expression or statement
uses the MATLAB interpreter to evaluate the expression or execute the statement contained in the text string s
.
The example of the previous section could also be done with the following code, although this would be somewhat less efficient because it involves the full interpreter, not just a function call.
for d = 1:31 s = ['load August' int2str(d) '.dat']; eval(s) % Process the contents of the d-th file end
Passing String Arguments to Functions | Vectorization |