Skip to content

evalin

Evaluate a string in a different workspace.

evalin(ws, expression)
[a1, a2, ...] = evalin(ws, expression)

Like eval but executes in the workspace named by ws — typically 'base' (the top-level interactive workspace) or 'caller' (the caller of the current function). Useful for accessing the base workspace from inside a function.

evalin('base', 'who') % list variables in the base workspace
evalin('caller', 'x') % retrieve x from the caller
  • eval — Execute a string as MathJet code.
  • evalc — Evaluate a string and capture its console output.
  • assign — Assign a value to a variable by name.