evalc
Evaluate a string and capture its console output.
Syntax
Section titled “Syntax”result = evalc(expression)[result, a1, a2, ...] = evalc(expression)Description
Section titled “Description”Executes expression and captures everything that would have been printed to the console as the string result. Side-effects on workspace variables still occur. Useful for testing functions whose primary effect is disp() / printf() output.
Example
Section titled “Example”out = evalc('disp(magic(3))') % out captures the printed matrix