Code covered by the BSD License  

Highlights from
Environment Capture

Be the first to rate this file! 1 Download (last 30 days) File Size: 1.99 KB File ID: #23434
image thumbnail

Environment Capture

by David Weinstein

 

25 Mar 2009

Capture the environment (or scope, maybe even call it a closure) of the function caller.

| Watch this File

File Information
Description

function env = env_capture(varargin)
% function env = env_capture(varargin)
% Capture the scope/environment of the caller. This is useful
% to snapshot in a running function all local (and local global)
% including persistent variables with their bindings.
%
% If no arguments provided, returns all bindings from caller context.
% Example execution:
% env = env_capture('ignore', 'ans', 'maxbytes', 100);
%
% Optional Input:
% varargin = keyword/argument pair: (keyed on first letter of keyword)
% +-------+----------+------------------------------------+
% |keyword| value | description |
% | |(example) | |
% +-------+----------+------------------------------------+
% | m | 1000 | maximum number of bytes of |
% | | | varibles to capture |
% +-------+----------+------------------------------------+
% | i | 'ans' | variable name to ignore |
% +-------+----------+------------------------------------+
%
% Output:
% env = <struct> whose fieldnames are the variables declared/bound
% in the scope of the caller and whose values are the
% values of the variables.
%
% Note: multiple variables can be ignored like in the following:
% env_capture('ignore', 'ans', 'ignore', 'beta', 'maxbytes', 1000);
%
% Author: David Weinstein (dweinst@alum.rpi.edu)

MATLAB release MATLAB 7.8 (R2009a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
02 Jun 2009 David Weinstein

I'm interested to know if anyone has found this function useful or had questions about its use.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
closure David Weinstein 27 Mar 2009 11:31:07
environment David Weinstein 27 Mar 2009 11:31:07
scope David Weinstein 27 Mar 2009 11:31:07
snapshot David Weinstein 27 Mar 2009 11:31:07
workspace David Weinstein 27 Mar 2009 11:31:07
whos David Weinstein 27 Mar 2009 11:31:07
bindings David Weinstein 27 Mar 2009 11:31:07
programming David Weinstein 27 Mar 2009 11:31:07
capture David Weinstein 27 Mar 2009 11:31:07

Contact us at files@mathworks.com